jenkins_api

Crates.iojenkins_api
lib.rsjenkins_api
version0.8.0
sourcesrc
created_at2018-03-25 15:46:02.175718
updated_at2020-05-23 17:39:09.130668
descriptionBindings for the Jenkins JSON API
homepagehttps://github.com/mockersf/jenkins-api.rs
repositoryhttps://github.com/mockersf/jenkins-api.rs
max_upload_size
id57393
size180,640
François Mockers (mockersf)

documentation

https://docs.rs/jenkins_api

README

jenkins-api.rs License: MIT Build Status Coverage Status Realease Doc Crate

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();
    }
}
Commit count: 337

cargo fmt