From 6a2f2232cb3bd26e512c1383a581544bc0aef731 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 17 Nov 2017 01:26:13 +0100 Subject: jenkins.rs: Add `jenkins_console_url_path()` A new function that will return the URL to the Jenkins "Console" page given the URL of a Jenkins job. We'll be using this to pass with the GitHub status request as the `target_url`. --- src/jenkins.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/jenkins.rs b/src/jenkins.rs index 2cd4858..67e6c20 100644 --- a/src/jenkins.rs +++ b/src/jenkins.rs @@ -281,6 +281,10 @@ pub fn result_from_job(status: Option) -> JobStatus { } } +pub fn jenkins_console_url_path(job_url: &String) -> String { + format!("{}console", job_url) +} + fn jenkins_request_client(user_id: &String, token: &String) -> Result> { let credentials = auth_credentials(user_id.to_owned(), token.to_owned()); @@ -446,4 +450,14 @@ mod tests { JobStatus::Pending ); } + + #[test] + fn jenkins_console_url_path_returns_url_to_console_page() { + assert_eq!( + jenkins_console_url_path( + &"https://jenkins.example.com/job/changes-branches/15/".to_owned() + ), + "https://jenkins.example.com/job/changes-branches/15/console" + ); + } } -- cgit v1.2.3 From ad9537963fe3eb6589ecdec0c6f9f001a483f5e2 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 17 Nov 2017 01:33:26 +0100 Subject: find_and_track_build_and_update_status(): Send Jenkins console URL When adding a GitHub commit status, instead of using the job "home" URL, use the URL of its "Console" page. This page shows the build log and is much more useful than the other one. If there's a build failure in particular, you'd be going to this page anyway to see what the problem was, so using this `target_url` saves a click. --- src/jenkins.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/jenkins.rs b/src/jenkins.rs index 67e6c20..72d375e 100644 --- a/src/jenkins.rs +++ b/src/jenkins.rs @@ -127,11 +127,13 @@ pub fn find_and_track_build_and_update_status( let commit_status = job.result.commit_status(); + let job_console_url = jenkins_console_url_path(&job_url); + github::update_commit_status( &github_token, &commit_ref, &commit_status, - job_url.clone(), + job_console_url.clone(), None, "continuous-integration/jenkins".to_owned() ).expect( @@ -161,7 +163,7 @@ pub fn find_and_track_build_and_update_status( &github_token, &commit_ref, &github::CommitStatus::Error, - job_url.clone(), + job_console_url.clone(), Some("The status checker timed out.".to_owned()), "continuous-integration/jenkins".to_owned() ).expect( @@ -191,7 +193,7 @@ pub fn find_and_track_build_and_update_status( &github_token, &commit_ref, &updated_job.result.commit_status(), - job_url.clone(), + job_console_url.clone(), None, "continuous-integration/jenkins".to_owned() ).expect( -- cgit v1.2.3