ARTIFACTORY: How to configure JFrog CLI Bitbucket Pipe

Soly Im
2022-04-11 08:20

This Bitbucket Pipe downloads, installs and configures JFrog CLI, so that it can be used as part of your YAML configuration.

Requirements: 

  • Bitbucket Pipelines
  • JFrog CLI version 1 

 
Configuring JFrog CLI on Local Machine: 

Before you can configure JFrog Bitbucket Pipe, you would need to configure JFrog CLI on your local machine first. In this example, we are using JFrog CLI version 1.47.0. 

To configure your JFrog CLI to Artifactory, please run #jfrog config add. A prompt will appear asking for your Artifactory URL and credentials. 

User-added image

Once done, please run to #jfrog rt ping to verify that the connection was made successfully. 
 

User-added image

Export JFrog CLI configuration: 

Once JFrog CLI has been configured successfully, you would need to export its configuration in order for you to use it in Bitbucket. To export, please run #jfrog config export <Server-ID>

User-added image

Copy the output of the above command and save it in a text file. 

Importing Configuration to Bitbucket:

To import JFrog CLI configuration to Bitbucket, you will need to create variables. These variables can either be workspace variables or repository variables. In this walkthrough, we will create a workspace variable that any project can access. 

On the Repositories page, click on Settings to the left of the page.
User-added image

Once you are in the Settings Page, create a variable called JF_ARTIFACTORY_<Desired_name> and paste the key from the export command as the value. Click add to save the variable.

Optional Variable: 
      JFROG_CLI_VERSION = Specify version of JFrog CLI for Bitbucket to download. If not specify, Bitbucket will use JFrog CLI version 1.37.1
 

User-added image
Adding JFrog CLI Pipe to Bitbucket YAML: 

Once you have the necessary variables added, you will need to add the below tasks to our Bitbucket Pipelines YAML file.  - pipe: jfrog/jfrog-setup-cli:1.0.0
             - source ./jfrog-setup-cli.sh

User-added image

Once added, you can perform a test run of our Pipelines to make sure there is no issue.
User-added image

Verifying Connection: 
To verify that Bitbucket was able to successfully connect to JFrog Artifactory, you can add a task to perform a ping to Artifactory.jfrog rt ping
User-added image
You should see an OK response from Artifactory if Bitbucket was able to successfully connect to Artifactory.

User-added image