Register CI build artifacts

3 minute read

Register build artifact metadata from your CloudBees CI or Jenkins® pipeline to CloudBees Unify to track and manage compiled binaries, configurations, log files, and other build outputs. Configure your Multibranch Pipeline to automatically register artifact information including version, digest, location, and associated commit details.

Before you begin, ensure you have completed the CI or Jenkins integration. For setup instructions, refer to Connect CI and Jenkins controllers.

Configure your Multibranch Pipeline to register build artifacts

Register any outputs of your integrated CI pipeline build workflow run, such as compiled binaries and log files, to CloudBees Unify.

To register artifacts from your CI build to CloudBees Unify:

  1. Specify a registerBuildArtifactMetadata step in your Jenkinsfile that contains the required inputs listed in the table below:

    Table 1. Input details
    Input name Data type Required? Description

    name

    String

    Yes

    The name of the artifact reported to CloudBees Unify.

    url

    String

    Yes

    The URL where the artifact version is located. For example, docker.io/myapp/myimg:1.0.0.

    version

    String

    Yes

    The version of the artifact to send to CloudBees Unify for artifact traceability purposes.

    digest

    String

    No

    The hash or checksum that uniquely identifies the artifact version.

    CloudBees recommends specifying the digest to track artifact versions across repositories. For more information, refer to Artifact deployment and publish history.

    label

    String

    No

    A comma-separated list of artifact labels.

    type

    String

    No

    The type of artifact, such as Docker or Maven.

    componentId

    String

    No

    The ID of the component associated with the artifact. If not provided, the default value is the component ID where the CloudBees CI / Jenkins workflow is located.

    commit

    String

    Only required if a different repository/branch.[1]

    The commit used to build the artifact. The default value is the commit hash from the CloudBees CI / Jenkins build.

    commitUrl

    String

    Only required if a different repository/branch.[1]

    The URL of the commit used to build the artifact. The default value is the commit URL from the CloudBees CI / Jenkins build.

    repositoryUrl

    String

    Only required if a different repository/branch.[1]

    The URL of the repository. The default value is the repository URL from the CloudBees CI / Jenkins build.

    ref

    String

    Only required if a different repository/branch.[1]

    The branch or tag ref used to build the artifact. The default value is the ref from the CloudBees CI / Jenkins build.

    [1] By default, the artifact version is associated with the code commit from the CI build. If a different commit/repository/branch has been checked out for building the artifact, specify those commit details instead. If you do not want to associate commit details with this artifact version, omit this parameter.

For the full parameter specification and syntax, refer to registerBuildArtifactMetadata reference.

Output

The registerBuildArtifactMetadata step returns the registered artifact’s UUID as a string. You can capture this value and pass it to subsequent steps, such as registerDeployedArtifactMetadata. For more information, refer to Register CI deployed artifacts.

Usage examples

Basic example

The following is a basic example of using the registerBuildArtifactMetadata step with only the required parameters, capturing the returned artifact ID:

pipeline { agent any stages { stage('Registering build artifact') { steps { script { def cbpArtifactId = registerBuildArtifactMetadata( name: "my-artifact", url: "https://my-artifact-url.com", version: "1.0.0" ) echo "Registered artifact: $cbpArtifactId" } } } } }

Advanced example with optional parameters

The following example specifies optional parameters:

pipeline { agent any stages { stage('Registering build artifact') { steps { echo 'Registering the metadata' registerBuildArtifactMetadata( name: "my-Docker-artifact", url: "https://hub.docker.com/repository/docker/example", version: "1.0.0", digest: "sha256:abcdef1234567890", label: "staging,prod", type: "Docker", componentId: "e04f06b0-992c-4267-b133-91092b252845", commit: "1234abcd-ab34-123cd-56ef-12345678abcd", commitUrl: "https://github.com/example/repo/commit/1234abcd-ab34-123cd-56ef-12345678abcd", repositoryUrl: "https://github.com/example/repo", ref: "refs/heads/main" ) } } } }

View CI build artifacts

View artifacts from your CI build in the same platform as all your other DevOps projects.

To view the artifacts for a build, do one of the following:

  • Access the details for your CI build, and then select Build artifacts to list only the artifacts generated during that build.

  • Select your component, and then select Artifacts to list all artifacts associated with a component. Choose to display only the latest versions or the entire version history.

View artifacts from build details

To view artifacts from a specific build:

  1. Select the organization and component associated with the CI build.

  2. Select Components  Runs.

  3. Select the build name to view build details.

  4. Select the Build artifacts tab to list only the artifacts generated during that build.

View all component artifacts

To view all artifacts associated with a component:

  1. Select your component.

  2. Select Components  Artifacts.

  3. Choose to display only the latest versions or the entire version history.

The artifact list displays the name, version, digest, location, and any labels for each registered artifact.