Crates.io | jenkins_api |
lib.rs | jenkins_api |
version | 0.8.0 |
source | src |
created_at | 2018-03-25 15:46:02.175718 |
updated_at | 2020-05-23 17:39:09.130668 |
description | Bindings for the Jenkins JSON API |
homepage | https://github.com/mockersf/jenkins-api.rs |
repository | https://github.com/mockersf/jenkins-api.rs |
max_upload_size | |
id | 57393 |
size | 180,640 |
Bindings to Jenkins JSON API
The API docs for the master branch are published here.
use jenkins_api::JenkinsBuilder;
use jenkins_api::build::BuildStatus;
use jenkins_api::job::BuildableJob;
fn main() {
let jenkins = JenkinsBuilder::new("http://localhost:8080")
.with_user("user", Some("password"))
.build().unwrap();
let job = jenkins.get_job("job name").unwrap();
let to_build = if let Some(short_build) = job.last_build.clone() {
let build = short_build.get_full_build(&jenkins).unwrap();
println!(
"last build for job {} at {} was {:?}",
job.name, build.timestamp, build.result
);
if let Some(result) = build.result {
result != BuildStatus::Success
} else {
true
}
} else {
println!("job {} was never built", job.name);
true
};
if to_build {
println!("triggering a new build");
job.as_variant::<jenkins_api::job::FreeStyleProject>().unwrap()
.build(&jenkins).unwrap();
}
}