HTTPS SSH

Bitbucket Pipelines Pipe: Artifactory Docker

This pipe uploads a Docker image to an JFrog Artifactory repository that serves as a Docker registry.

By default, this pipe will also capture build-info and publish it to Artifactory as metadata associated with the uploaded file.

YAML Definition

Add the following snippet to the script section of your bitbucket-pipelines.yml file:

- pipe: JfrogDev/artifactory-docker:0.2.12
  variables:
    ARTIFACTORY_URL: '<string>'
    ARTIFACTORY_USER: '<string>'
    ARTIFACTORY_PASSWORD: '<string>'
    DOCKER_IMAGE_TAG: '<string>'
    DOCKER_TARGET_REPO: '<string>'
    # BUILD_NAME: '<string>' # Optional.
    # JFROG_CLI_TEMP_DIR: '<string>' # Optional.
    # JFROG_CLI_HOME_DIR: '<string>' # Optional.
    # COLLECT_ENV: '<boolean>' # Optional.
    # COLLECT_GIT_INFO: '<boolean>' # Optional.
    # COLLECT_BUILD_INFO: '<boolean>' # Optional.
    # EXTRA_ARGS: '<string>' # Optional.
    # EXTRA_BAG_ARGS: '<string>' # Optional.
    # DEBUG: '<boolean>' # Optional.

Variables

Variable Usage
ARTIFACTORY_URL (*) The JFrog Artifactory URL .
ARTIFACTORY_USER (*) Artifactory User with permission to upload artifacts.
ARTIFACTORY_PASSWORD (*) Password for Artifactory User.
DOCKER_IMAGE_TAG (*) Docker image tag.
DOCKER_TARGET_REPO (*) Artifactory Docker registry to store the Docker image.
BUILD_NAME Build Name. Default: $BITBUCKET_REPO_OWNER-$BITBUCKET_REPO_SLUG-$BITBUCKET_BRANCH
JFROG_CLI_TEMP_DIR Specifies the JFrog CLI temp directory. Default: .
JFROG_CLI_HOME_DIR Specifies the JFrog CLI home directory.Default: .
COLLECT_ENV This flag is used to collect environment variables and attach them to a build. Default: true
COLLECT_GIT_INFO This flag is used to collects the Git revision and URL from the local .git directory and adds it to the build-info. Default: true
COLLECT_BUILD_INFO This flag is used to publish build info to Artifactory. Default: true
EXTRA_ARGS Extra arguments to be passed to the JFrog CLI command (see JFrog CLI docs for more details). Defaults to unset.
EXTRA_BAG_ARGS Extra arguments to be passed to the build-add-git (bag) JFrog CLI command (see JFrog CLI docs for more details). Defaults to unset.
DEBUG Set to true to output additional debug information. Default: false.

(*) = required variable.

Details

After building your image using the docker client, this pipe pushes the image layers to Artifactory collecting the build-info and publishes it to Artifactory.

Prerequisites

JFrog Artifactory details are necessary to use this pipe.

Examples

Basic example

script:
  # Build docker image using docker build command with build number as tag
  - docker build -t soldev-art-docker.jfrog.team/docker-pipe-example:$BITBUCKET_BUILD_NUMBER .
  # Publish Docker image to Artifactory docker registry
  - pipe: JfrogDev/artifactory-docker:0.2.12
    variables:
      ARTIFACTORY_URL: '<string>'
      ARTIFACTORY_USER: '${ARTIFACTORY_USER}'
      ARTIFACTORY_PASSWORD: '${ARTIFACTORY_PASSWORD}'
      DOCKER_IMAGE_TAG: 'soldev-art-docker.jfrog.team/docker-pipe-example:${BITBUCKET_BUILD_NUMBER}'
      DOCKER_TARGET_REPO: 'docker-stage-local'

Advanced example

  • Complete Example of building, publishing, scanning and promoting docker image to Artifactory using JFrog Pipes.
    - step:
        services:
        - docker
        name: "docker-pipe-example"
        script:
        - docker build -t soldev-art-docker.jfrog.team/docker-pipe-example:$BITBUCKET_BUILD_NUMBER .
        # Build and publish Docker image to Artifactory
        - pipe: JfrogDev/artifactory-docker:0.2.12
          variables:
            ARTIFACTORY_URL: $ARTIFACTORY_URL
            ARTIFACTORY_USER: $ARTIFACTORY_USER
            ARTIFACTORY_PASSWORD: $ARTIFACTORY_PASSWORD
            DOCKER_IMAGE_TAG: "soldev-art-docker.jfrog.team/docker-pipe-example:${BITBUCKET_BUILD_NUMBER}"
            DOCKER_TARGET_REPO: "docker-stage-local"
            FOLDER: "docker"
            BUILD_NAME: "docker-pipe-example"
        # Scan published build through Xray
        - pipe: JfrogDev/artifactory-xray-scan:0.2.7
          variables:
            ARTIFACTORY_URL: $ARTIFACTORY_URL
            ARTIFACTORY_USER: $ARTIFACTORY_USER
            ARTIFACTORY_PASSWORD: $ARTIFACTORY_PASSWORD
            BUILD_NAME: "docker-pipe-example"
        # Promote Build in Artifactory
        - pipe: JfrogDev/artifactory-build-promotion:0.2.10
          variables:
            ARTIFACTORY_URL: $ARTIFACTORY_URL
            ARTIFACTORY_USER: $ARTIFACTORY_USER
            ARTIFACTORY_PASSWORD: $ARTIFACTORY_PASSWORD
            TARGET_REPO: "docker-prod-local"
            STATUS: "Staged"
            BUILD_NAME: "docker-pipe-example"
        # Promote Build in Artifactory
        - pipe: JfrogDev/artifactory-build-promotion:0.2.10
          variables:
            ARTIFACTORY_URL: $ARTIFACTORY_URL
            ARTIFACTORY_USER: $ARTIFACTORY_USER
            ARTIFACTORY_PASSWORD: $ARTIFACTORY_PASSWORD
            TARGET_REPO: "docker-prod-local"
            STATUS: "Promoted"
            BUILD_NAME: "docker-pipe-example"

Support

If you'd like help with this pipe, or you have an issue or feature request, let us know on.

If you're reporting an issue, please include:

  • the version of the pipe
  • relevant logs and error messages
  • steps to reproduce

License

Apache 2.0 licensed, see LICENSE file.