jenkins_api_redux

Crates.iojenkins_api_redux
lib.rsjenkins_api_redux
version0.1.1
sourcesrc
created_at2023-04-26 19:11:12.616131
updated_at2023-04-26 19:15:27.878772
descriptionBindings for the Jenkins JSON API; a fork of https://github.com/mockersf/jenkins-api.rs
homepagehttps://github.com/j7nw4r/jenkins-api-redux.rs
repositoryhttps://github.com/j7nw4r/jenkins-api-redux.rs
max_upload_size
id849746
size178,198
Johnathan W (j7nw4r)

documentation

https://docs.rs/jenkins_api_redux

README

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

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

cargo fmt