Artifactory
There are many ways to use Artifactory with Buildkite. This document covers how to configure the Buildkite Agent's built-in Artifactory support, as well as how to use Artifactory's package management features in your Buildkite pipelines.
Buildkite Agent's Artifactory support
The Buildkite Agent can upload and download artifacts directly from Artifactory. Export the following environment variables in your Agent environment hook to configure the Agent's Artifactory support.
See the Managing pipeline secrets documentation for how to securely set up these environment variables.
Required environment vars:
BUILDKITE_ARTIFACT_UPLOAD_DESTINATION |
The Artifactory repository and path that will be used to upload and download artifacts, starting with an rt:// prefix Example: "rt://some-repo/build-$BUILDKITE_BUILD_NUMBER/$BUILDKITE_JOB_ID/" |
BUILDKITE_ARTIFACTORY_URL |
Your Artifactory instance URL, including the /artifactory suffixExample: https://my-artifactory-server/artifactory |
BUILDKITE_ARTIFACTORY_USER |
The username of a user configured in your Artifactory instance Example: some-user |
BUILDKITE_ARTIFACTORY_PASSWORD |
The API Key, Access Token, or password for your Artifactory user Example: AKCp5dKiQ9syTzu9GFhpF3iTzDcFhYAa4... |
Once the above environment variables are configured, all artifact uploads and downloads will use Artifactory. For example, the following command step will build a binary and upload it to Artifactory using the artifact_paths
attribute:
Retrieving artifacts using the Buildkite Agent
The Buildkite Agent uses Buildkite's APIs to fetch the correct URLs to download artifacts from Artifactory. By default, the agent searches for artifacts uploaded within the same build. To download artifacts that were uploaded in different builds using buildkite-agent artifact download
or artifacts-buildkite-plugin, pass the BUILDKITE_BUILD_ID
of the job through which the artifact was uploaded, as additional information to the --build
option's argument.
Using Artifactory for package management
To help cache and secure your build dependencies, you can use Artifactory's package management features in your Buildkite pipelines. Each package management platform is configured differently.
For example, to use an Artifactory NPM registry in your build steps, you can configure the following Agent environment hook to instruct the npm command to use Artifactory instead of npmjs.com:
export NPM_CONFIG_REGISTRY="https://${BUILDKITE_ARTIFACTORY_USER}:${BUILDKITE_ARTIFACTORY_PASSWORD}@my-artifactory-server/artifactory/api/npm/npm-local/"
You can use this same approach for Ruby gem repositories, Docker registries, and any other Artifactory supported package managers.
If you're running build steps in a Docker container, you'll need to ensure the package management configuration is available inside the container. For example, if you're testing Node in a container, you'll need to pass through the above NPM_CONFIG_REGISTRY
environment variable into the container: