JFrog Help Center

Our new portal is coming soon!
Documentation + Knowledge Base





JFrog Help Center - A new knowledge experience is coming your way soon!



Overview

ThePromoteBuildnative step promotes a BuildInfo and moves or copies the related artifacts from one Artifactory repository to another.


This step requires aBuildInforesource as an input to successfully execute.
Page Contents


YAML Schema

The YAML schema for PromoteBuild native step is as follows:

PromoteBuild
pipelines: - name:  steps: - name:  type: PromoteBuild configuration: #inherits all the tags from bash; //www.si-fil.com/confluence/display/JFROG/Bash targetRepository:  includeDependencies:  # default false status:  comment:  copy:  inputResources: - name:  # required trigger: false outputResources: - name:  # required execution: onStart: - echo "Preparing for work..." onSuccess: - echo "Job well done!" onFailure: - echo "uh oh, something went wrong" onComplete: #always - echo "Cleaning up some stuff"

Tags

name

Analphanumericstring (underscores are permitted) that identifies the step.

type

Must bePromoteBuildfor this step type.

configuration

Specifies all configuration selections for the step's execution environment.This step inherits theBash/PowerShellstep configuration tags, including these pertinenttags:

Tag

Description of usage

Required/Optional
inputResources Must specify a namedBuildInforesource whosebuildNameandbuildNumberproperties identify the build to promote. Required
outputResources Must specify a namedBuildInforesourceto map to the promoted build.The BuildInfo will be updated with thebuildNameandbuildNumberof the input BuildInfo resource, and itstargetRepowith the value oftargetRepository. Required


In addition, these tags can be defined to support the step's native operation:

来自本地所有步骤Bashstep. This means that all steps share the same base set of tags from Bash, while native steps have their own additional tags as well that support the step's particular function. So it's important to be familiar with theBashstep definition, since it's the core of the definition of all other steps.

Tag

Description of usage

Required/Optional
targetRepository The name of the repository in Artifactory to promote the build to. Required
includeDependencies

When set to true, promotion will include the build dependencies.

Defaults to false.

Optional
status Name of the status to promote the build to. Optional
comment Comment to include for the promotion. Optional
copy

When set to true, copies the artifacts to the targetRepository vs moving them to the targetRepository.

Defaults to false.

Optional

execution

Declares collections of shell command sequences to perform for pre- and post-execution phases:

Tag

Description of usage

Required/Optional
onStart Commands to execute in advance of the native operation Optional
onSuccess Commands to execute on successful completion Optional
onFailure Commands to execute on failed completion Optional
onComplete Commands to execute on any completion Optional


The actions performed for theonExecutephase are inherent to this step type and may not be overridden.


Examples

The following examples show how to configure a PromoteBuild step.

Promote Build to Artifactory

Promotes a build specified by an input BuildInfo to an Artifactory repository nameddocker-prod-local. In this example,triggeris set asfalseon the input resource so that the step will not be automatically triggered.

PromoteBuild
#这个配置文件模板,以便它可以be easily customized. Values can be provided with a values.yml file. template: true # required for local templates valuesFilePath: ./values.yml resources: - name: app_repo type: GitRepo configuration: gitProvider: {{ .Values.gitIntegration }} path: {{ .Values.gitRepositoryPath }} branches: include: master - name: app_buildinfo type: BuildInfo configuration: sourceArtifactory: {{ .Values.artifactoryIntegration }} - name: app_promoted_buildinfo type: BuildInfo configuration: sourceArtifactory: {{ .Values.artifactoryIntegration }} pipelines: - name: app_dev_pipeline_su204 steps: - name: app_build type: DockerBuild configuration: affinityGroup: docker_group dockerFileLocation: . dockerFileName: Dockerfile dockerImageName: {{ .Values.artifactoryUrl }}/{{ .Values.sourceRepository }}/{{ .Values.imageName }} dockerImageTag: ${run_number} inputResources: - name: app_repo integrations: - name: {{ .Values.artifactoryIntegration }} - name: app_push type: DockerPush configuration: affinityGroup: docker_group targetRepository: {{ .Values.sourceRepository }} integrations: - name: {{ .Values.artifactoryIntegration }} inputSteps: - name: app_build - name: publish_app_build type: PublishBuildInfo configuration: affinityGroup: docker_group inputSteps: - name: app_push outputResources: - name: app_buildinfo - name: xrayScanStep type: XrayScan configuration: inputResources: - name: app_buildinfo - name: app_prod_pipeline_su204 steps: - name: app_promote_build type: PromoteBuild configuration: targetRepository: {{ .Values.prodRepository }} inputResources: - name: app_buildinfo trigger: false outputResources: - name: app_promoted_buildinfo - name: app_deploy type: Bash configuration: integrations: - name: {{ .Values.artifactoryIntegration }} inputResources: - name: app_promoted_buildinfo execution: onStart: - jfrog rt docker-pull {{ .Values.artifactoryUrl }}/{{ .Values.prodRepository }}/{{ .Values.imageName }}:$res_app_promoted_buildinfo_buildNumber {{ .Values.prodRepository }} #- jfrog rt dl prod-go-local/app #- ls -latr onExecute: - docker run {{ .Values.artifactoryUrl }}/{{ .Values.prodRepository }}/{{ .Values.imageName }}:$res_app_promoted_buildinfo_buildNumber

Promote Build with Status and Comment

Promotes the build with a status and comment.

PromoteBuild
pipelines: - name: promoteBuildPipeline steps: - name: promoteBuildStep type: PromoteBuild configuration: targetRepository: my-promoted-builds status: TEST comment: "Promoted by run number ${run_number}." integrations: - name: artifactory_integration inputResources: - name: inputBuildInfo trigger: false outputResources: - name: outputBuildInfo

Promote Build and Copy

In this example, when the build is promoted, it is copied so that a copy remains in the previous repository and the dependencies are copied as well as the build.

PromoteBuild
pipelines: - name: promoteBuildPipeline steps: - name: promoteBuildStep type: PromoteBuild configuration: targetRepository: my-promoted-builds includeDependencies: true copy: true integrations: - name: artifactory_integration inputResources: - name: inputBuildInfo trigger: false outputResources: - name: outputBuildInfo

How it Works

When you use thePromoteBuildnative step in a pipeline, it performs the following functions in the background:

  • jfrog rt config (configure the JFrog CLI with the credentials in the BuildInfo input)
  • jfrog rt build-promote
  • write_output (update the output BuildInfo resource)
  • No labels
Copyright © 2023 JFrog Ltd.