2 releases
0.1.1 | Apr 26, 2023 |
---|---|
0.1.0 | Apr 26, 2023 |
155KB
3.5K
SLoC
jenkins-api-redux.rs
ATTENTION: This crate is a fork of jenkins-api.rs. It is an attempt to fully flesh out Jenkins compatiblity (Jenkins api key and async support).
CURRENTLY IN DEVELOPMENT
This crate provides bindings to Jenkins JSON API.
Example
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();
}
}
Dependencies
~5–19MB
~303K SLoC