From 0e6fad71021dfda057936cb9ce79a33706cb4967 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 8 Nov 2017 01:35:30 +0100 Subject: jenkins.rs: Add `update_commit_status` outline Outline for the main function that will integrate everything here. It carries out the algorithm described at the top of the file. So far it's incomplete, but wanted to get the idea down in code somewhere. Also, this method might make more sense in a different module. --- src/jenkins.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/jenkins.rs b/src/jenkins.rs index 428b561..8965c6a 100644 --- a/src/jenkins.rs +++ b/src/jenkins.rs @@ -33,6 +33,20 @@ pub enum JobStatus { Unknown, } +pub fn update_commit_status(commit_ref) { + let jobs = get_jobs(); + + for job_url in jobs { + let payload = request_job(job_url); + + // Does `displayName` match + if job_for_commit(payload, commit_ref) { + // spawn thread + let status = result_from_job(payload); + } + } +} + pub fn auth_credentials() -> Basic { Basic { username: "username".to_string(), @@ -53,6 +67,10 @@ pub fn get_jobs(repo_name: String) {//-> Vec { println!("{}", res.status()); } +// Does the `commit_ref` correspond to the job in the `payload`? +pub fn job_for_commit(payload: String, commit_ref: CommitRef) -> bool { +} + pub fn result_from_job(payload: String) -> JobStatus { let mut job = json::parse(payload.as_ref()).unwrap(); -- cgit v1.2.3