aboutsummaryrefslogtreecommitdiffstats
path: root/src/jenkins.rs
AgeCommit message (Collapse)Author
2017-11-09github.rs: `update_commit_status` needs organisation nameTeddy Wing
I wasn't thinking straight in 26b74edece4546378c8a853cc70f7388f20ff0c6. Instead of taking a repo name, we need to take an organisation/user name. The repo name we already have from `commit_ref.repo`. We were missing the org to be able to properly construct the GitHub API URL. Pass `organization_name` name around from `find_and_track_build_and_update_status`.
2017-11-09jenkins.rs: Take repo name in `find_and_track...`Teddy Wing
This function should take a repo name so we can pass that information to `get_jobs`, as well as `update_commit_status`. Also add types to the parameters which I apparently didn't think to do the first time.
2017-11-09jenkins.rs: Start `thread` idea in main functionTeddy Wing
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).
2017-11-09jenkins.rs: Rename `update_commit_status` functionTeddy Wing
Realised tonight that I had used the same name for this function and for the function in `github.rs` that updates the commit status on GitHub. Since it doesn't really make sense for these two different functions to have the same name, rename this one to be more specific about what it does.
2017-11-08jenkins.rs: Fix `request_job` testTeddy Wing
Pass the correct URL into the function call. Previously my copy-pastes meant that the mock URL I had defined was different from the one I passed to `request_job`.
2017-11-08jenkins.rs: Allow `request_job` to work with the test mockTeddy Wing
Use the 'url' crate to split the passed in URL string and get its path part so we can use the mock HTTP server for testing. Otherwise, this requested the real Jenkins API URL and we couldn't test it.
2017-11-08jenkins.rs: Initial `request_job` implementationTeddy Wing
Try to request a job from the Jenkins API and return it as a `Job`. Trouble is, we can't mock this because the 'mockito' mocker depends on `API_URL`. Right now, we're making a request to the real server, not the mock server.
2017-11-08jenkins.rs: Add test for `request_job`Teddy Wing
This function will get a `Job` based on the response from requesting a single build job from the Jenkins API.
2017-11-08jenkins.rs: Make `get_jobs` realTeddy Wing
Instead of just making a request to test out 'reqwest' and how to use it, make this function actually do something useful. It now requests a URL dynamically based on the `repo_name` passed in, and returns a list of build job URLs from the JSON resulting from the API response.
2017-11-08jenkins.rs: Make `get_jobs` test realTeddy Wing
Instead of just calling the `get_jobs` function, make this a real test and check its return value using a mocked response, now that we have 'mockito' at our disposition.
2017-11-08jenkins.rs: Add `job_for_commit`Teddy Wing
Fill in this function, which returns a boolean whether a given job matches a `CommitRef`. It does this based on the display name of the job. Needed to make the `Job` struct public in order to use it here.
2017-11-08jenkins.rs: Add `Job::new` function to create Job from JSON payloadTeddy Wing
Now we can parse the JSON payload in a single place and extract the values from it into a new `Job`. Change `Job.result`'s type to `JobStatus` because that makes more sense. Now, `result_from_job` gets called in `Job::new` to give us the `JobStatus` directly on the `Job`. Modify `result_from_job` to fit into its new responsibility, working for `Job::new`. Update the tests accordingly.
2017-11-08jenkins.rs: Add a `Job` typeTeddy Wing
This will avoid having to parse a job JSON payload multiple times. We should do the parsing once, extract the data we need, and pass the resulting struct around instead.
2017-11-08jenkins.rs: Add `update_commit_status` outlineTeddy Wing
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.
2017-11-08jenkins.rs: Add `result_from_job`Teddy Wing
This method will take a job JSON payload returned from the Jenkins API (http://jenkins/job/:project/:id/api/json), and return its status, success, failed, or pending. A new `JobStatus` type represents the status of jobs.
2017-11-07jenkins.rs: Add `get_jobs`, test HTTP requestTeddy Wing
Try making our first HTTP request to the Jenkins API. Use Basic authentication with our name and access token. The 'reqwest' format is based on https://doc.rust-lang.org/stable/std/string/struct.String.html Eventually this method should return a `Vec` of jobs, actually job URLs, but at least we know it works and gives us a 200.
2017-11-07jenkins.rs: Outline commit status update algorithmTeddy Wing
Comment and a rough interface definition describing how commit statuses should be updated and how Jenkins should be queried.
2017-11-07Add modules for GitHub and Jenkins interactionTeddy Wing
Empty stub modules that will be filled in with the communication code.