Deployment Build Marker

The Deployment Build Marker can be used to mark a build as a deployment to a specific environment.

Pipelines

In a pipeline job, builds can be marked using the generic step declaration. The step takes three arguments, namely environmentId, environmentName, and environmentType. Both environmentId and environmentName are strings where the id is limited to 40 characters and the name to 255 characters, whereas environmentType can have any of the following values, development, testing, staging, production and unmapped. The last is also used in case a different value is provided.

pipeline {
  agent any
  stages {
    stage('Deploy to Staging') {
      steps {
        echo 'Build and deploy to staging'
      }
      post {
        always {
          step([$class: 'DeploymentBuildMarker', environmentId: 'eu-staging-1', environmentName: 'Staging', environmentType: 'staging'])
        }
      }
    }
  }
}

At a bare minimum the Deployment Build Marker only needs the environmentType when it’s executing as part of a pipeline. Take the snippet below.

pipeline {
  agent any
  stages {
    stage('Deploy to Staging') {
      steps {
        echo 'Build and deploy to staging'
      }
      post {
        always {
          step([$class: 'DeploymentBuildMarker', environmentType: 'production'])
        }
      }
    }
  }
}

In this case the environmentName will be set to production, and the environmentId will be generated using the environmentName as input.

Traditional Jobs

In a traditional Jenkins job, like a free style job, builds can be marked using the Deployment Build Marker as post build action, simply add the action and specify the environment id, name and type using the action form.


Previous: Search by Build
Next: Trigger a Build
Docs - Jenkins Integration for Jira

Didn’t find what you were looking for?