The following examples show how to configure a DockerPush step to push a Docker image. For more information on DockerPush Pipeline steps, see DockerPush.
Push Image to Artifactory
Pushes the image created by the DockerBuild input step to Artifactory. Does not trigger a scan.
This example requires an Artifactory Integration or JFrog Platform Access Token Integration and a GitHub Integration.
The Pipelines DSL for this example is available in this repository in the JFrog GitHub account.
For a full tutorial, see Pipeline Example: Docker Build and Push.
DockerPush
# This config file is templatized so that it can be easily customized. Values can be provided with a values.yml file. template: true # required for local templates valuesFilePath: ./values.yml resources: - name: app_repo1 type: GitRepo configuration: gitProvider: {{ .Values.gitIntegration }} path: {{ .Values.gitRepositoryPath }} branches: include: master - name: app_buildinfo1 type: BuildInfo configuration: sourceArtifactory: {{ .Values.artifactoryIntegration }} - name: app_promoted_buildinfo1 type: BuildInfo configuration: sourceArtifactory: {{ .Values.artifactoryIntegration }} pipelines: - name: app_dev_pipeline 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
Affinity Group
This extends one of the DockerBuild examples, pushing that image to Artifactory. Note that an affinity group has been specified in both steps.
DockerPush
pipelines: - name: demo_pipeline steps: - name: bld_image type: DockerBuild configuration: affinityGroup: dockerGroup dockerFileLocation: . dockerFileName: Dockerfile dockerImageName: docker.artprod.mycompany.com/gosvc # replace with your fully qualified Docker registry/image name dockerImageTag: ${run_number} dockerOptions: --build-arg build_number_env_variable=${run_number} inputResources: - name: gosvc_app integrations: - name: MyArtifactory - name: dockerPushStep type: DockerPush configuration: affinityGroup: dockerGroup targetRepository: dockerRepo inputSteps: - name: bld_image outputResources: - name: outputBuildInfo integrations: - name: MyArtifactory
Publish Build Info, Trigger Xray Scan, Update Output Image Resource
In this, publishing build info, triggering an Xray scan, and updating an output Image resource has been added to the previous example.
DockerPush
pipelines: - name: demo_pipeline steps: - name: bld_image type: DockerBuild configuration: affinityGroup: dockerGroup dockerFileLocation: . dockerFileName: Dockerfile dockerImageName: docker.artprod.mycompany.com/gosvc # replace with your fully qualified Docker registry/image name dockerImageTag: ${run_number} dockerOptions: --build-arg build_number_env_variable=${run_number} inputResources: - name: gosvc_app integrations: - name: MyArtifactory - name: dockerPushStep type: DockerPush configuration: affinityGroup: dockerGroup targetRepository: dockerRepo autoPublishBuildInfo: true forceXrayScan: true inputSteps: - name: bld_image outputResources: - name: outputBuildInfo - name: outputImage integrations: - name: MyArtifactory