This topic provides an example of a Docker and Push YAML examine named pipelines.yaml. For information about the Pipeline Example Docker and Build Push, see Docker and Build Push Example: pipelines.yml.
The pipelines.yml file is made up of resources, pipelines and steps, as shown below:
Resources
This example uses the following types of resources:
GitRepo
Image
BuildInfo
GitRepo
A GitRepo resource is used to connect JFrog Pipelines to a source control repository. Adding it creates a webhook to the repo so that future commits will automatically create a new version with the webhook payload.
resources
- name: dbp_repo
type: GitRepo
configuration:
gitProvider: my_github # <-- replace with your integration
path: jfrog/jfrog-pipelines-docker-sample # <-- replace with your repository name
branches:
include: master
Tag | Description | Required/Optional |
|---|---|---|
name |
This name is used to refer to the resource in steps, and must be unique across all repositories in your JFrog Pipelines environment. | Required |
| The name of the GitHub Integration. | Required |
| The path of the repository from the integration root. | Required |
|
The | Optional |
Image
An Image resource is used to add a reference to a Docker image to your pipeline. An Image resource can be used as both input and output. Steps like DockerBuild will generate it as an output and steps like DockerPublish will use it as input to publish to a Docker registry. In our example, it is used as an outputResource for the DockerPush step.
resources
- name: dbp_image
type: Image
configuration:
registry: art # <-- replace with your artifactory integration
sourceRepository: docker_local # <-- required if registry is Artifactory
imageName: docker.artprod.mycompany.com/docker_local/dbp # < -- replace with your image path and name
imageTag: latest
autoPull: true
Tag | Description | Required/Optional |
|---|---|---|
|
| Required |
|
| Required |
|
| Required if registry is in JFrog Artifactory |
| The file path of the Docker image, of the form imageRepo/imageName. | Required |
| The version tag of the initial version of the Docker image. | Required |
| When true, the image is automatically pulled to the machine running the step. Defaults to false. | Optional |
BuildInfo
BuildInfo is automatically created when the DockerBuild step is used to generate packages. BuildInfo is then published to the configured Artifactory repo (sourceArtifactory: art) through the PublishBuildInfo step, by providing that resource in the DockerPush step.
resources
- name: dbp_build_info
type: BuildInfo
configuration:
sourceArtifactory: art
buildName: dbp_build
buildNumber: 1
- name: dbp_promoted_build_info
type: BuildInfo
configuration:
sourceArtifactory: art
buildName: dbp_build
buildNumber: 1Tag | Description | Required/Optional |
|---|---|---|
name |
This name is used to refer to the resource in steps, and must be unique across all repositories in your JFrog Pipelines environment. | Required |
|
| Required |
buildName |
| Optional |
buildNumber | The number of the build to associate with the BuildInfo. | Optional |
Pipelines
pipeline_dbp, the pipeline definition for building and pushing the Docker image.
Steps
The pipeline_dbp pipeline contains the following native steps:
DockerBuild
DockerPush
PublishBuildInfo
PromoteBuild
DockerBuild
The DockerBuild native step performs a build to produce a Docker image from a Dockerfile in a Git source repository.
This step builds a Docker image from a GitRepo source repository resource. You must provide in the step configuration the name and directory of the Dockerfile that contains the command to be processed by a docker build command, as well as the name and tag of the resulting image. The image is built on the build node, and information about that image is stored in the run state.
steps
- name: docker_build
type: DockerBuild
configuration:
affinityGroup: dbp_group
dockerFileLocation: .
dockerFileName: Dockerfile
dockerImageName: docker.artprod.mycompany.com/docker_local/dbp # replace with your image path and name
dockerImageTag: ${run_number}
inputResources:
- name: dbp_repo
integrations:
- name: art # <-- replace with your artifactory integration
Tag | Description of usage | Required/Optional |
|---|---|---|
name |
This is the name that is used when the step is assigned as an input to the next step, | Required |
| Must specify an affinity group string that is the same as specified in a subsequent DockerPush step. Both DockerBuild and DockerPush steps are assigned to the dbp_group affinityGroup so that they share the same state. If they are not, the output of the DockerBuild step won't be available to the DockerPush step. | Optional |
| Directory containing the Dockerfile or the file that has Docker build configuration | Required |
| Name of the Dockerfile | Required |
| The name of the Docker image to create. This can be set using environment variables or triggering a run using parameters. | Required |
| The tag for the Docker image to create. This can be set using environment variables or triggering a run using parameters. In our example, the tag for the image is set to the pipeline's run number, which is the number of the run currently executing. | Required |
| Must specify:
This step accepts `dbp_repo` as an inputResource to build the image based on the provided Dockerfile. Optionally, may also specify: | Required/Optional |
| Must specify an Artifactory Integration. | Required |
DockerPush
The DockerPush native step pushes the specified Docker Image to Artifactory.
steps
- name: docker_push
type: DockerPush
configuration:
affinityGroup: dbp_group
targetRepository: docker-local
integrations:
- name: art # <-- replace with your artifactory integration
inputSteps:
- name: docker_build
outputResources:
- name: dbp_image
Tag | Description of usage | Required/Optional |
|---|---|---|
name |
| Required |
| Must specify an affinity group string that is the same as specified in the prior DockerBuild step. | Optional |
| The name of the Docker repository in Artifactory. | Required |
| Must specify an Artifactory Integration or JFrog Platform Access Token Integration . | Required |
| Must specify the named DockerBuild step in the same affinity group. The output (result) of the previous | Required |
| May specify an Image resource. If one is specified, the This step outputs `dbp_image` as an outputResource, which can be used to trigger downstream dependent steps or pipelines if needed. | Optional May be required |
PublishBuildInfo
The PublishBuildInfo step publishes BuildInfo attached to the image to Artifactory. BuildInfo provides a manifest for the build and includes metadata about the modules, dependencies and other environment variables.
BuildInfo can also be published by any of the language-specific publish steps, when its autoPublishBuildInfo tag is set to true.
steps
- name: publish_dbp_build
type: PublishBuildInfo
configuration:
inputSteps:
- name: docker_push
outputResources:
- name: dbp_build_info
Tag | Description of usage | Required/Optional |
|---|---|---|
name |
| Required |
| Must specify the name of the DockerPush step. The output (result) of the previous step is used as an inputStep for this step. The step must nothave set | Required |
| Must specify a BuildInfo resource to publish. | Required |
PromoteBuild
The PromoteBuild native step promotes the dbp_build_info BuildInfo and moves or copies the related artifacts from one Artifactory repository to another.
steps
This step requires either a PublishBuildInfo step as previous step or a BuildInfo resource as an input to successfully execute.
- name: promote_dbp_build
type: PromoteBuild
configuration:
targetRepository: demo-pipelines
integrations:
- name: art
inputResources:
- name: dbp_build_info
outputResources:
- name: dbp_promoted_build_info
Tag | Description of usage | Required/Optional |
|---|---|---|
name |
| Required |
targetRepository |
| Required |
| Must specify an Artifactory Integration or JFrog Platform Access Token Integration . | Required |
| Must specify a named BuildInfo resource whose | Required |
| Must specify a named BuildInfo resource to map to the promoted build. The BuildInfo will be updated with the | Required |