aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2017-11-12 19:22:52 +0100
committerTeddy Wing2017-11-12 19:22:52 +0100
commitc3eac830c7713f2e2740b95fe2ef3664ae0a021d (patch)
tree52c50ef271f3d6d3b831957800ebc9e0b5edf9d1 /src
parent1b2f71944f50ae3032737c0566c20ad046789b37 (diff)
downloadkipper-c3eac830c7713f2e2740b95fe2ef3664ae0a021d.tar.bz2
update_commit_status(): Pass GitHub token from command line argument
Take the GitHub API token as a parameter and pass it through from `find_and_track_build_and_update_status()`.
Diffstat (limited to 'src')
-rw-r--r--src/github.rs3
-rw-r--r--src/jenkins.rs5
-rw-r--r--src/main.rs2
3 files changed, 7 insertions, 3 deletions
diff --git a/src/github.rs b/src/github.rs
index 731d261..83a5526 100644
--- a/src/github.rs
+++ b/src/github.rs
@@ -34,6 +34,7 @@ impl fmt::Display for CommitStatus {
}
pub fn update_commit_status(
+ github_token: &String,
commit_ref: &CommitRef,
state: &CommitStatus,
target_url: String,
@@ -68,7 +69,7 @@ pub fn update_commit_status(
.header(
Authorization(
Bearer {
- token: "token".to_owned()
+ token: github_token.to_owned()
}
)
)
diff --git a/src/jenkins.rs b/src/jenkins.rs
index fd72e73..b46f5ae 100644
--- a/src/jenkins.rs
+++ b/src/jenkins.rs
@@ -79,7 +79,7 @@ pub fn find_and_track_build_and_update_status(
jenkins_url: &String,
jenkins_user_id: &String,
jenkins_token: &String,
- github_token: &String,
+ github_token: String,
) -> Result<(), Box<Error>> {
let jenkins_client = jenkins_request_client(
&jenkins_user_id,
@@ -115,6 +115,7 @@ pub fn find_and_track_build_and_update_status(
let commit_status = job.result.commit_status();
github::update_commit_status(
+ &github_token,
&commit_ref,
&commit_status,
job_url.clone(),
@@ -142,6 +143,7 @@ pub fn find_and_track_build_and_update_status(
if now.elapsed().as_secs() == t20_minutes {
github::update_commit_status(
+ &github_token,
&commit_ref,
&github::CommitStatus::Error,
job_url.clone(),
@@ -171,6 +173,7 @@ pub fn find_and_track_build_and_update_status(
if job.result != updated_job.result {
github::update_commit_status(
+ &github_token,
&commit_ref,
&job.result.commit_status(),
job_url.clone(),
diff --git a/src/main.rs b/src/main.rs
index b03b963..fdcdeeb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -108,7 +108,7 @@ fn main() {
&jenkins_url,
&jenkins_user_id,
&jenkins_token,
- &github_token,
+ github_token.clone(),
) {
Ok(_) => {},
Err(_) => return internal_server_error(),