Deploy to Artifactory
In this how-to guide, you will learn how to upload artifacts to Artifactory in CircleCI.
Introduction
Artifactory has documentation explaining how to use their REST API.
Below are some sample projects showing how to best use CircleCI and Artifactory together. Ensure that you have created your repository before starting this example, otherwise CircleCI will not have a place to store your dependencies.
Artifactory plugins
Popular tools like Maven and Gradle have Artifactory plugins, and can deploy to Artifactory using their respective deploy commands.
JFrog CLI
If you want to use the JFrog CLI, you can install it by following the steps below.
1. Add JFrog to your configuration
Add the following to your .circleci/config.yml
:
- run:
name: Install jFrog CLI
command: curl -fL https://getcli.jfrog.io | sh
2. Configure credentials
Now you need to configure JFrog to use CircleCI credentials securely. CircleCI configures the client to use $ARTIFACTORY_URL
, along with $ARTIFACTORY_USER
and $ARTIFACTORY_APIKEY
. These can be entered under Project Settings->Environment Variables
. Configure the CLI to use these settings:
- run: ./jfrog config add <named_server_config> --artifactory-url $ARTIFACTORY_URL --user $ARTIFACTORY_USER --apikey $ARTIFACTORY_APIKEY --interactive=false
3. Upload JAR files (optional)
If you would like to upload JAR files use the following example:
- run: ./jfrog rt u "multi*/*.jar" <artifactory_repo_name> --build-name=<name_you_give_to_build> --build-number=$CIRCLE_BUILD_NUM --flat=false
4. Upload WAR files (optional)
If you would like to upload WAR files use the following example:
- run: ./jfrog rt u "multi*/*.war" <artifactory_repo_name> --build-name=<name_you_give_to_build> --build-number=$CIRCLE_BUILD_NUM --flat=false
Full configuration example
The full .circleci/config.yml
file would look something like the following:
version: 2.1
jobs:
upload-artifact:
docker:
- image: cimg/openjdk:19.0.1
working_directory: ~/repo
steps:
- checkout
- run: mvn dependency:go-offline
- run:
name: maven build
command: |
mvn clean install
- run:
name: Install JFrog CLI
command: curl -fL https://getcli.jfrog.io | sh
- run:
name: Push to Artifactory
command: |
./jfrog config add <named_server_config> --artifactory-url $ARTIFACTORY_URL --user $ARTIFACTORY_USER --apikey $ARTIFACTORY_APIKEY --interactive=false
./jfrog rt u <path/to/artifact> <artifactory_repo_name> --build-name=<name_you_give_to_build> --build-number=$CIRCLE_BUILD_NUM
./jfrog rt bce <name_you_give_to_build> $CIRCLE_BUILD_NUM # collects all environment variables on the agent
./jfrog rt bp <name_you_give_to_build> $CIRCLE_BUILD_NUM # attaches ^^ to the build in artifactory
See also
Help make this document better
This guide, as well as the rest of our docs, are open source and available on GitHub. We welcome your contributions.
- Suggest an edit to this page (please read the contributing guide first).
- To report a problem in the documentation, or to submit feedback and comments, please open an issue on GitHub.
- CircleCI is always seeking ways to improve your experience with our platform. If you would like to share feedback, please join our research community.
Need support?
Our support engineers are available to help with service issues, billing, or account related questions, and can help troubleshoot build configurations. Contact our support engineers by opening a ticket.
You can also visit our support site to find support articles, community forums, and training resources.
CircleCI Documentation by CircleCI is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.