Skip to content

The action is used to inform CloudBees Platform of a deployed artifact version

License

Notifications You must be signed in to change notification settings

cloudbees-io/register-deployed-artifact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CloudBees action: Register an artifact deployed to an environment

Use this action to report artifact-related data to an environment from a CloudBees Unify workflow run, for artifact traceability purposes.

Important

This action version (v2.0) is the most recent release of the action. Previous releases are deprecated. Version 2.0 replaces multiple required inputs with a single parameter, artifact-id.

Prerequisites

Before using this action, you must first register the artifact you plan to deploy to an environment. This registration saves the artifact information to the CloudBees Unify.

Do one of the following to save your artifact information to the CloudBees Unify:

Inputs

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

artifact-id

String

Yes

The unique identifier of an artifact.

target-environment

String

Required if no job-level environment is specified.

The environment where the deployment is located. The target-environment value overrides the jobs.<job_id>.environment value.

labels

String

No

A comma-separated list of artifact labels. NOTE: A maximum of 20 labels are allowed per artifact version, with a maximum of 20 characters per label.

Usage examples

Basic example

The following is a basic example of using the action:

 jobs:
    register_artifact_version_to_my_env:
      environment: my_env
      steps:
        - name: Register deployed artifact
          uses: cloudbees-io/register-deployed-artifact@v2
          with:
            artifact-id: 1234abcd-56ef-ab78-9012-cdef78903456

Using optional inputs

The following example specifies artifact labels:

 jobs:
    register_artifact_version_to_qa_env:
      environment: qa_env
      steps:
        - name: Register deployed artifact with labels
          uses: cloudbees-io/register-deployed-artifact@v2
          with:
            artifact-id: 1234abcd-56ef-ab78-9012-cdef78903456
            labels: label1,label2

Full workflow example with Kaniko

This example publishes an image with Kaniko, and then reports the data to the CloudBees Unify.

apiVersion: automation.cloudbees.io/v1alpha1
kind: workflow
name: Deployment workflow

on:
  workflow_dispatch:

jobs:
  build:
    outputs:
      artifact-id: ${{ fromJSON(steps.push-image.outputs.artifact-ids)[ format('index.docker.io/{0}/my-sample-go-app:{1}', vars.DOCKER_USERNAME, cloudbees.version) ] }}
    steps:
      - uses: docker://alpine/git:latest
        run: |
          git config --global --add safe.directory /cloudbees/workspace
      - name: checkout
        uses: cloudbees-io/checkout@v1
      - name: Build Go app
        uses: docker://golang:1.20
        kind: build
        run: |
          go build -v ./...
      - name: Set up Docker Hub registry
        uses: cloudbees-io/configure-oci-credentials@v1
        kind: deploy
        with:
          registry: index.docker.io
          username: ${{ vars.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      - name: Push image to OCI registry
        id: push-image
        uses: cloudbees-io/kaniko@v1
        with:
          destination: index.docker.io/${{ vars.DOCKER_USERNAME }}/my-sample-go-app:${{cloudbees.version}}
  deploy:
    needs: build
    steps:
      - name: Register deployed artifact
        uses: cloudbees-io/register-deployed-artifact@v2
        with:
          artifact-id: ${{ needs.build.outputs.artifact-id }}
          target-environment: dev

License

This code is made available under the MIT license.

References

About

The action is used to inform CloudBees Platform of a deployed artifact version

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 9