Trait Artifact

pub trait Artifact: Serialize + DeserializeOwned {
    const TAR_GZ_NAME: Option<&'static str> = None;
}
Expand description

A trait representing a collection of files that can be published to or resolved from a pipeline artifact.

This can be used with publish_typed_artifact and resolve_typed_artifact to publish or resolve artifacts between jobs in a pipeline in a structured way.

By implementing this trait, you are guaranteeing that the type serializes into JSON in a format reflecting a directory structure, where each key is a file name and each value is either a string containing the path to the file, or another JSON object representing a subdirectory.

For example, you might have Rust types like this:

#[derive(Serialize, Deserialize)]
struct Artifact {
    #[serde(rename = "file.exe")]
    file: PathBuf,
    subdir: Option<Inner>,
}

#[derive(Serialize, Deserialize)]
struct Inner {
    #[serde(rename = "file2.exe")]
    file2: PathBuf,
}

This would serialize into JSON like this:

{
   "file.exe": "path/to/file.exe",
  "subdir": {
      "file2.exe": "path/to/file2.exe"
  }
}

Which would in turn reflect a directory structure like this:

- file.exe
- subdir/
  - file2.exe

Provided Associated Constants§

const TAR_GZ_NAME: Option<&'static str> = None

If present, the published artifact should consist of a tar.gz file containing the contents of the artifact.

This is mostly useful for artifacts with lots of files. Some backends (specifically Azure DevOps) apparently cannot cope with this.

An alternate approach would be to detect this automatically, and/or to only do it for the affected backends. Currently, we don’t bother with this complexity, preferring instead a predictable and consistent approach.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§