Allow specifying a title for each job
diff mbox

Message ID 20170203071129.22938-1-andrew.donnellan@au1.ibm.com
State Accepted
Headers show

Commit Message

Andrew Donnellan Feb. 3, 2017, 7:11 a.m. UTC
From: Russell Currey <ruscur@russell.cc>

Currently we just report the name of the job as the name of the check we
report to Patchwork.  This is problematic if we want to run the same
Jenkins job multiple times with different configurations, so allow
specifying an explicit title for each job we kick off.

Signed-off-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
---

already merged, for information only

---
 src/main.rs     | 10 ++++++----
 src/settings.rs |  7 +++++++
 2 files changed, 13 insertions(+), 4 deletions(-)

Patch
diff mbox

diff --git a/src/main.rs b/src/main.rs
index e5ad03f..d27ddd6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -106,18 +106,19 @@  fn run_tests(settings: &Config, client: Arc<Client>, project: &Project, tag: &st
     let project = project.clone();
     for job_params in &project.jobs {
         let job_name = job_params.get("job").unwrap();
+        let job_title = settings::get_job_title(job_params);
         let mut jenkins_params = Vec::<(&str, &str)>::new();
         for (param_name, param_value) in job_params.iter() {
             debug!("Param name {}, value {}", &param_name, &param_value);
             match param_name.as_ref() {
                 // TODO: Validate special parameter names in config at start of program
-                "job" => { },
+                "job" | "title" => { },
                 "remote" => jenkins_params.push((param_value, &project.remote_uri)),
                 "branch" => jenkins_params.push((param_value, tag)),
                 _ => jenkins_params.push((param_name, param_value)),
             }
         }
-        info!("Starting job: {}", &job_name);
+        info!("Starting job: {}", &job_title);
         let res = jenkins.start_test(job_name, jenkins_params)
             .unwrap_or_else(|err| panic!("Starting Jenkins test failed: {}", err));
         debug!("{:?}", &res);
@@ -132,9 +133,10 @@  fn run_tests(settings: &Config, client: Arc<Client>, project: &Project, tag: &st
         debug!("Build URL: {}", build_url_real);
         jenkins.wait_build(&build_url_real);
         let test_result = jenkins.get_build_result(&build_url_real).unwrap();
-        info!("Jenkins job for {}/{} complete.", branch_name, job_name);
+        info!("Jenkins job for {}/{} complete.", branch_name, job_title);
         results.push(TestResult {
-            test_name: format!("{}/{}", branch_name.to_string(), job_name.to_string()),
+            test_name: format!("Test {} on branch {}", job_title.to_string(),
+                               branch_name.to_string()).to_string(),
             state: test_result,
             url: Some(jenkins.get_results_url(&build_url_real, job_params)),
             summary: Some("TODO: get this summary from Jenkins".to_string()),
diff --git a/src/settings.rs b/src/settings.rs
index 2d30e7c..b2cd4d6 100644
--- a/src/settings.rs
+++ b/src/settings.rs
@@ -79,6 +79,13 @@  pub struct Config {
     pub projects: BTreeMap<String, Project>
 }
 
+pub fn get_job_title(job: &BTreeMap<String, String>) -> String {
+    match job.get("title") {
+        Some(title) => title.to_string(),
+        None => job.get("job").unwrap().to_string()
+    }
+}
+
 pub fn parse(path: String) -> Config {
     let mut toml_config = String::new();