Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Is there a way to download an artifact? #80

@elazarl

Description

@elazarl

It is currently possible with the API to get a list of the artifacts of the job. It is even possible to get the URL of the specific artifact:

fn main() -> Result<(), Box<dyn Error>> {
    let user = "elazarl";
    let token = "d4bf510c5963520355749a7da277182aaa";
    let jenkins = JenkinsBuilder::new("http://localhost:8000/")
        .with_user(user, Some(token))
        .build().unwrap();
    let build = jenkins.get_build("End2EndReport", 2590)?;
    println!("curl --user {}:{} {}artifact/{}", user, token, build.url, build.artifacts[0].relative_path);
    Ok(())
}

However I couldn't find a way to use Jenkins to download it:

  1. The client itself seems to be private, and there's no way to access it.
  2. All methods of getting a generic object or Path from jenkins, seems to convert it to json, hence disabling download of logs.

Is there a way to download a generic artifact?

Something like

impl Jenkins {
    pub fn get_artifact(build: Build, artifact: Artifact) -> Box<dyn std::io::Read> {
        let query = self
            .client
            .get(&format!("{}artifact/{}", &build.url, artifact.relative_path));
        Ok(Self::error_for_status(self.send(query)?)?)
    }

Does that make sense? Is there any other way to achieve that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions