From patchwork Fri Feb 3 07:11:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 723430 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vF7P25wH4z9s76 for ; Fri, 3 Feb 2017 18:12:54 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vF7P252WzzDqBj for ; Fri, 3 Feb 2017 18:12:54 +1100 (AEDT) X-Original-To: snowpatch@lists.ozlabs.org Delivered-To: snowpatch@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vF7Nx0tvgzDqBZ for ; Fri, 3 Feb 2017 18:12:48 +1100 (AEDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1379Hj1008129 for ; Fri, 3 Feb 2017 02:12:46 -0500 Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) by mx0a-001b2d01.pphosted.com with ESMTP id 28c3wp7sas-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 03 Feb 2017 02:12:46 -0500 Received: from localhost by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 3 Feb 2017 17:12:32 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 3 Feb 2017 17:12:30 +1000 Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 3B8E12CE8046 for ; Fri, 3 Feb 2017 18:12:30 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v137CM8A14352402 for ; Fri, 3 Feb 2017 18:12:30 +1100 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v137BvCp023883 for ; Fri, 3 Feb 2017 18:11:58 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v137Bvhm023440; Fri, 3 Feb 2017 18:11:57 +1100 Received: from ajd.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id A29C8A01EA; Fri, 3 Feb 2017 18:11:33 +1100 (AEDT) From: Andrew Donnellan To: snowpatch@lists.ozlabs.org Date: Fri, 3 Feb 2017 18:11:29 +1100 X-Mailer: git-send-email 2.11.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020307-0044-0000-0000-000002268C81 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020307-0045-0000-0000-00000678384C Message-Id: <20170203071129.22938-1-andrew.donnellan@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-03_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702030073 Subject: [snowpatch] [PATCH] Allow specifying a title for each job X-BeenThere: snowpatch@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Continuous Integration for patch-based workflows List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: snowpatch-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "snowpatch" From: Russell Currey 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 Signed-off-by: Andrew Donnellan --- already merged, for information only --- src/main.rs | 10 ++++++---- src/settings.rs | 7 +++++++ 2 files changed, 13 insertions(+), 4 deletions(-) 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, 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 {}", ¶m_name, ¶m_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, 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 } +pub fn get_job_title(job: &BTreeMap) -> 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();