diff options
| author | Teddy Wing | 2017-11-09 00:25:34 +0100 | 
|---|---|---|
| committer | Teddy Wing | 2017-11-09 00:38:56 +0100 | 
| commit | 2d3b362513d7e256f6a1ed3bdeed2eb785302ff3 (patch) | |
| tree | 311a42f2cc8ffe35becccdc3bfe7777610d03bfb | |
| parent | 675926019dc6782d009f53ff267e1d97d9eb0267 (diff) | |
| download | kipper-2d3b362513d7e256f6a1ed3bdeed2eb785302ff3.tar.bz2 | |
jenkins.rs: Start `thread` idea in main function
Use `thread::spawn` and update the GitHub commit status. Write an
outline for how to handle polling for changes and updating the GitHub
commit status on success or failure (or timeout).
| -rw-r--r-- | src/jenkins.rs | 33 | 
1 files changed, 29 insertions, 4 deletions
| diff --git a/src/jenkins.rs b/src/jenkins.rs index 42fe6e4..d87c508 100644 --- a/src/jenkins.rs +++ b/src/jenkins.rs @@ -25,6 +25,8 @@ extern crate mockito;  extern crate reqwest;  extern crate url; +use std::thread; +  use self::reqwest::header::{Authorization, Basic};  use self::url::Url; @@ -65,12 +67,35 @@ pub fn find_and_track_build_and_update_status(commit_ref) {      let jobs = get_jobs();      for job_url in jobs { -        let payload = request_job(job_url); +        let job = request_job(job_url);          // Does `displayName` match -        if job_for_commit(payload, commit_ref) { -            // spawn thread -            let status = result_from_job(payload); +        if job_for_commit(job, commit_ref) { +            thread::spawn(|| { +                // Start timer + +                github::update_commit_status( +                    commit_ref, +                    job.commit_status().result, +                    job_url, +                    None, +                    "continuous-integration/jenkins".to_string() +                ); + +                if job.result == JobStatus::Pending { +                    // loop +                    // if timer > 20 minutes +                    //   call github::update_commit_status with timeout error +                    //   return +                    // wait 30 seconds +                    // call request_job again +                    // if the status is different +                    //   call github::update_commit_status +                    //   stop +                } +            }); + +            return          }      }  } | 
