16 unstable releases (7 breaking)
0.8.0 | May 23, 2020 |
---|---|
0.7.0 | Nov 17, 2019 |
0.6.0 | Sep 16, 2019 |
0.5.2 | Nov 10, 2018 |
0.1.1 | Mar 25, 2018 |
#19 in #jenkins
133 downloads per month
Used in 8 crates
(6 directly)
155KB
3.5K
SLoC
jenkins-api.rs
Bindings to Jenkins JSON API
The API docs for the master branch are published here.
Example
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();
}
}
Dependencies
~5–12MB
~242K SLoC