Crates.io | jenkins_api_redux |
lib.rs | jenkins_api_redux |
version | 0.1.1 |
source | src |
created_at | 2023-04-26 19:11:12.616131 |
updated_at | 2023-04-26 19:15:27.878772 |
description | Bindings for the Jenkins JSON API; a fork of https://github.com/mockersf/jenkins-api.rs |
homepage | https://github.com/j7nw4r/jenkins-api-redux.rs |
repository | https://github.com/j7nw4r/jenkins-api-redux.rs |
max_upload_size | |
id | 849746 |
size | 178,198 |
This crate provides bindings to Jenkins JSON API.
use jenkins_api_redux::JenkinsBuilder;
use jenkins_api_redux::build::BuildStatus;
use jenkins_api_redux::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_redux::job::FreeStyleProject>().unwrap()
.build(&jenkins).unwrap();
}
}