From patchwork Tue Dec 11 03:46:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell Currey X-Patchwork-Id: 1010830 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43DQy30c16z9s3Z for ; Tue, 11 Dec 2018 14:52:43 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=russell.cc Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="gM/uZTSK"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 43DQy24pTvzDqPK for ; Tue, 11 Dec 2018 14:52:42 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=russell.cc Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="gM/uZTSK"; dkim-atps=neutral X-Original-To: snowpatch@lists.ozlabs.org Delivered-To: snowpatch@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (helo) smtp.helo=out1-smtp.messagingengine.com (client-ip=66.111.4.25; helo=out1-smtp.messagingengine.com; envelope-from=ruscur@russell.cc; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=russell.cc Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="gM/uZTSK"; dkim-atps=neutral Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 43DQxx3grRzDqD2 for ; Tue, 11 Dec 2018 14:52:37 +1100 (AEDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id B7EF821D2E; Mon, 10 Dec 2018 22:45:44 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 10 Dec 2018 22:45:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=1QRgjGfiH13ms8ddTlh4kBf1+wmjN/DF79plT9ZRqZA=; b=gM/uZTSK AMg4kltCLaCOKdY5qiaQTkrGWwvbQgz4YjFnjAsay/6VGKx7r0n++ELus7AiH6eQ MUGHoQ3GodFOiQbIRvjTHin05pj4MgURvlO1FHVH+wgrG6mzIk+8v9qF5NWpC8T4 mbZv5BvyyruYlOsO1H4KG7PcUnenHM19OmlvJYRuIByxpcjMgJACmhj8Q5Wfttiu wqMWw6vND4f5kXgmqS2MiHfzWEfwJJAuDKHw7pnxxVBxSNXCfHmrmBZxdT0Xc2yV vu5lQxBxIlovoEE4GJZqW6SicSL42rbw3AboFaakZ55WKGvIXhPcUybqu5KDW8lN nVQtlESQrc82mA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegiedgieegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecufghrlhcuvffnffculdeftddmnecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpeftuhhsshgvlhhlucevuhhrrhgvhicuoehruhhstghurhes rhhushhsvghllhdrtggtqeenucffohhmrghinhepshhtrghtuhhsrdhishenucfkphepvd dtvddrkedurddukedrfedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehruhhstghurhes rhhushhsvghllhdrtggtnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from crackle.ozlabs.ibm.com.au.ibm.com (bh02i525f01.au.ibm.com [202.81.18.30]) by mail.messagingengine.com (Postfix) with ESMTPA id 1E7A3E4430; Mon, 10 Dec 2018 22:45:42 -0500 (EST) From: Russell Currey To: snowpatch@lists.ozlabs.org Date: Tue, 11 Dec 2018 14:46:00 +1100 Message-Id: <20181211034601.29061-4-ruscur@russell.cc> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181211034601.29061-1-ruscur@russell.cc> References: <20181211034601.29061-1-ruscur@russell.cc> MIME-Version: 1.0 Subject: [snowpatch] [PATCH v2 4/5] Allow retrieving a check's description from Jenkins artifact X-BeenThere: snowpatch@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Continuous Integration for patch-based workflows List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell Currey Errors-To: snowpatch-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "snowpatch" By specifying the "description" parameter in a job, take the contents of a Jenkins artifact and use it to populate the description field. Closes #49 Signed-off-by: Russell Currey --- src/jenkins.rs | 20 ++++++++++++++++++++ src/main.rs | 9 ++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/jenkins.rs b/src/jenkins.rs index 4906139..1fbcc49 100644 --- a/src/jenkins.rs +++ b/src/jenkins.rs @@ -197,6 +197,26 @@ impl JenkinsBackend { } } + pub fn get_description( + &self, + build_url: &str, + job: &BTreeMap, + ) -> Option { + match job.get("description") { + Some(artifact) => match self.get_url(&format!("{}/artifact/{}", build_url, artifact)) { + Ok(mut resp) => match resp.status().is_success() { + true => match resp.text() { + Ok(text) => Some(text), + Err(_e) => None, + }, + false => None, + }, + Err(_e) => None, + }, + None => None, + } + } + pub fn wait_build(&self, build_url: &str) -> JenkinsBuildStatus { // TODO: Implement a timeout? while self.get_build_status(build_url) != JenkinsBuildStatus::Done { diff --git a/src/main.rs b/src/main.rs index 6fe0bdb..c002b8b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -148,9 +148,12 @@ fn run_tests( test_result = TestState::Warning; } results.push(TestResult { - description: Some( - format!("Test {} on branch {}", job.title, branch_name.to_string()).to_string(), - ), + description: match jenkins.get_description(&build_url_real, &job.parameters) { + Some(description) => Some(description), + None => Some( + format!("Test {} on branch {}", job.title, branch_name.to_string()).to_string(), + ), + }, state: test_result, context: Some(job.title.replace("/", "_")), target_url: Some(jenkins.get_results_url(&build_url_real, &job.parameters)),