JFrog Setup CLI Bitbucket Pipe
Install and configure JFrog CLI in Bitbucket Pipelines.
The JFrog Setup CLI pipe copies a setup script into a Bitbucket Pipelines step. When you source that script, it downloads JFrog CLI, configures authentication, and exports build metadata so later lines can run jf commands.
The pipe does not build, upload, scan, or publish build-info by itself. Those actions happen in the jf commands you add after source.
Note
Use
jfrog/jfrog-setup-cli:2.2.0and pin the tag. Authenticate with OIDC when your JFrog and Bitbucket configuration supports it. Use a secured Config Token when OIDC is not available.
Prerequisites
- A Bitbucket Cloud repository with Pipelines enabled.
- A JFrog Platform URL.
- Either of the following:
- A Config Token stored in a secured
JF_ENV_*variable. - A JFrog OIDC integration and a Bitbucket step with
oidc: true.
- A Config Token stored in a secured
- Network access to
https://install-cli.jfrog.io. - Package tools required by commands you run after setup.
- A local repository of the matching package type, deploy plus publish-build-info permission, and the same build name and number on later
jfcommands.
Before You Begin
The pipe only installs JFrog CLI. You still publish artifacts and build-info in later lines. For more information, see How Build Integration Works and Choose Plugin, CLI, or CI Wrapper.
Pipe 2.2.0 always downloads JFrog CLI from https://install-cli.jfrog.io. It has no private mirror setting.
Quick Start With a Config Token
Create the Config Token
On a trusted machine:
jf config add
jf config export <SERVER_ID>Where:
<SERVER_ID>: The ID of the JFrog CLI server configuration to export
For example:
jf config add
jf config export my-jfrog-serverStore the complete output from jf config export as a secured Bitbucket repository or workspace variable. Name the variable with the JF_ENV_ prefix, such as JF_ENV_PROD. Do not encode the token again.
Add the Pipe
pipelines:
default:
- step:
name: Verify JFrog connection
script:
- pipe: jfrog/jfrog-setup-cli:2.2.0
- source ./jfrog-setup-cli.sh
- jf rt pingExpected result: the sourced script installs JFrog CLI, imports every JF_ENV_* and JF_ARTIFACTORY_* Config Token, removes the setup script, and jf rt ping reports a successful Artifactory connection.
Warning
The
sourcecommand must run in the same step, immediately before commands that needjf. The pipe container only copiesjfrog-setup-cli.sh. It does not change the parent step environment by itself.
Authenticate With OpenID Connect
OIDC support starts in pipe 2.2.0 and requires JFrog CLI 2.75.0 or later. Pipe 2.2.0 defaults to CLI 2.56.1, so you must override the CLI version for OIDC.
Configure JFrog
To configure a JFrog OIDC integration for Bitbucket Pipelines:
- In Bitbucket repository settings, open the OpenID Connect page and copy the provider URL and the repository and workspace identifiers.
- In JFrog Access, create a Generic OpenID Connect integration.
- Add identity mappings for the Bitbucket claims you trust.
- Copy the JFrog OIDC provider name.
Configure the Pipeline
pipelines:
default:
- step:
name: Verify JFrog with OIDC
oidc: true
script:
- pipe: jfrog/jfrog-setup-cli:2.2.0
- export JFROG_CLI_VERSION="2.75.0"
- export JF_URL="https://<JFROG_PLATFORM_HOST>"
- export JF_OIDC_PROVIDER_NAME="<OIDC_PROVIDER_NAME>"
- source ./jfrog-setup-cli.sh
- jf rt pingWhere:
<JFROG_PLATFORM_HOST>: Host name of your JFrog Platform<OIDC_PROVIDER_NAME>: Name of the JFrog OIDC integration you created
Optional values:
- export JF_OIDC_AUDIENCE="<AUDIENCE>"
- export JF_CUSTOM_SERVER_ID="<SERVER_ID>"Where:
<AUDIENCE>: Audience value requested for the OIDC token<SERVER_ID>: JFrog CLI server ID to use instead of the default
The default OIDC server ID is jfrog-setup-cli-server. The script configures JFrog CLI with provider type GenericOidc and the Bitbucket step token.
How the Pipe Works
- The pipe image copies
jfrog-setup-cli.shinto the step workspace. source ./jfrog-setup-cli.shdownloads JFrog CLI.- If OIDC variables are present, the script adds an OIDC server configuration.
- The script imports all
JF_ENV_*andJF_ARTIFACTORY_*Config Tokens. - It exports build name, number, URL, and a Bitbucket user agent.
- It removes
./jfrog-setup-cli.sh. - Later lines in the same step run
jf.
Use jf, not the deprecated jfrog command. The script defines alias jfrog=jf, but non-interactive shells do not reliably expand aliases.
Configuration Reference
The following table lists the variables the setup script reads. For definitions of build-info terms, see Build Integration Glossary.
| Variable | Purpose and default |
|---|---|
JF_ENV_* | Secured Config Token imported with jf config import. Preferred prefix. |
JF_ARTIFACTORY_* | Also imported as a Config Token. |
JF_URL | Your JFrog Platform URL. Required with OIDC. |
JF_OIDC_PROVIDER_NAME | JFrog OIDC integration name. |
JF_OIDC_AUDIENCE | Optional OIDC audience. |
JF_CUSTOM_SERVER_ID | OIDC server ID. Default is jfrog-setup-cli-server. |
JFROG_CLI_VERSION | CLI version. Default is 2.56.1. The latest value delegates version choice to the installer. |
JFROG_CLI_BUILD_NAME | Default $BITBUCKET_REPO_OWNER-$BITBUCKET_REPO_SLUG-$BITBUCKET_BRANCH. |
JFROG_CLI_BUILD_NUMBER | Default $BITBUCKET_BUILD_NUMBER. |
JFROG_CLI_BUILD_URL | Default Bitbucket Pipelines result URL. |
JFROG_CLI_BUILD_PROJECT | Optional JFrog project key for build commands. |
If you import multiple servers, run jf config use <SERVER_ID> before commands that must target a specific server.
Publish Generic Artifacts and Build Information
Replace repository names with repositories from your JFrog Platform:
script:
- pipe: jfrog/jfrog-setup-cli:2.2.0
- source ./jfrog-setup-cli.sh
- printf "hello from Bitbucket\n" > artifact.txt
- jf rt u artifact.txt <GENERIC_LOCAL_REPO>/
- jf rt bce
- jf rt bpWhere:
<GENERIC_LOCAL_REPO>: Target generic local repository in Artifactory
jf rt bp publishes the build name and number exported by the setup script. Without that command, the pipe does not create a build run. For more information about the record these commands publish, see About Build Info.
What You Should See Next
Open Builds in Artifactory. Find the build named:
<WORKSPACE_OWNER>-<REPOSITORY_SLUG>-<BRANCH>Where:
<WORKSPACE_OWNER>: Bitbucket workspace owner<REPOSITORY_SLUG>: Bitbucket repository slug<BRANCH>: Bitbucket branch name
The run number should match BITBUCKET_BUILD_NUMBER. Confirm the uploaded artifact and captured environment before adding scan or promotion commands.
Maven Example
script:
- pipe: jfrog/jfrog-setup-cli:2.2.0
- source ./jfrog-setup-cli.sh
- jf mvn-config --server-id-resolve=<SERVER_ID> --repo-resolve-releases=<RELEASES_VIRTUAL> --repo-resolve-snapshots=<SNAPSHOTS_VIRTUAL> --server-id-deploy=<SERVER_ID> --repo-deploy-releases=<RELEASES_LOCAL> --repo-deploy-snapshots=<SNAPSHOTS_LOCAL>
- jf mvn clean deploy
- jf rt bce
- jf rt bpWhere:
<SERVER_ID>: JFrog CLI server ID configured by the setup script<RELEASES_VIRTUAL>: Virtual repository used to resolve release dependencies<SNAPSHOTS_VIRTUAL>: Virtual repository used to resolve snapshot dependencies<RELEASES_LOCAL>: Local repository used to deploy releases<SNAPSHOTS_LOCAL>: Local repository used to deploy snapshots
Add jf rt bag --config=./issues-collection.yml before publish only when the configuration file exists and you intend to collect issues. Run jf bs after a successful publish to scan the build, and jf rt bpr <TARGET_REPO> only after validating promotion permissions.
Gradle Example
script:
- pipe: jfrog/jfrog-setup-cli:2.2.0
- source ./jfrog-setup-cli.sh
- jf gradle-config --server-id-resolve=<SERVER_ID> --repo-resolve=<RESOLVE_REPO> --server-id-deploy=<SERVER_ID> --repo-deploy=<DEPLOY_REPO>
- jf gradle clean build
- jf rt bce
- jf rt bpWhere:
<SERVER_ID>: JFrog CLI server ID configured by the setup script<RESOLVE_REPO>: Repository used to resolve dependencies<DEPLOY_REPO>: Repository used to deploy packages
The npm, Go, NuGet, and pip examples use the same placeholders.
npm Example
script:
- pipe: jfrog/jfrog-setup-cli:2.2.0
- source ./jfrog-setup-cli.sh
- jf npm-config --server-id-resolve=<SERVER_ID> --repo-resolve=<RESOLVE_REPO> --server-id-deploy=<SERVER_ID> --repo-deploy=<DEPLOY_REPO>
- jf npm ci
- jf npm publish
- jf rt bce
- jf rt bpGo Example
script:
- pipe: jfrog/jfrog-setup-cli:2.2.0
- source ./jfrog-setup-cli.sh
- jf go-config --server-id-resolve=<SERVER_ID> --repo-resolve=<RESOLVE_REPO> --server-id-deploy=<SERVER_ID> --repo-deploy=<DEPLOY_REPO>
- jf go build
- jf go-publish <MODULE_VERSION>
- jf rt bce
- jf rt bpWhere:
<MODULE_VERSION>: Version of the Go module to publish
NuGet and pip Examples
NuGet restore:
- jf nuget-config --server-id-resolve=<SERVER_ID> --repo-resolve=<RESOLVE_REPO>
- jf nuget restore
- jf rt bce
- jf rt bppip install:
- jf pip-config --server-id-resolve=<SERVER_ID> --repo-resolve=<RESOLVE_REPO> --server-id-deploy=<SERVER_ID> --repo-deploy=<DEPLOY_REPO>
- jf pip install -r requirements.txt
- jf rt bce
- jf rt bpDocker Example
- jf docker login
- jf docker pull <REGISTRY>/<IMAGE>:<TAG>
- jf docker push <REGISTRY>/<IMAGE>:<TAG>
- jf rt bce
- jf rt bpWhere:
<REGISTRY>: Docker registry host name for your Artifactory Docker repository<IMAGE>: Image name<TAG>: Image tag
The Bitbucket runner must provide a working Docker daemon and network access to the Artifactory registry.
Air-Gapped Runners, Proxies, and Certificates
Pipe 2.2.0 runs:
curl -fL https://install-cli.jfrog.io | shTherefore:
- An air-gapped runner cannot use this pipe unless it can reach that endpoint.
- Set
HTTP_PROXY,HTTPS_PROXY, andNO_PROXYon the step when required. - Install custom certificate authorities in the runner or container trust store.
- The pipe does not install custom CAs or expose an installer mirror variable.
Troubleshooting
The following table lists common problems and their resolutions.
| What you see | Cause | What to do |
|---|---|---|
JFrog CLI Installation failed. | Installer completed without putting jf on PATH. | Check access to install-cli.jfrog.io, proxy settings, and shell output. |
Error: JF_URL is required when JF_OIDC_PROVIDER_NAME is set. | OIDC was selected without a Platform URL. | Export JF_URL before source. |
OIDC configuration requires JFrog CLI version 2.75.0 or later. | OIDC is using the 2.56.1 default or another older CLI. | Set JFROG_CLI_VERSION to 2.75.0 or later, or latest. |
jf config import fails | Config Token is truncated, encoded again, expired, or collides with an existing server. | Export a fresh token and store its exact output as a secured variable. |
jf: command not found | The setup script was not sourced in this step. | Add source ./jfrog-setup-cli.sh before the first jf command. |
jfrog: command not found | A non-interactive shell did not expand the alias. | Use jf. |
| 401 or 403 | Authentication succeeded but permissions are missing or token expired. | Refresh credentials and check repository and build permissions. |
| Build missing in Artifactory | jf rt bp did not run or failed. | Publish after commands that collect build data and inspect that line's output. |
Frequently Asked Questions
This section provides answers to frequently asked questions.
FAQs
Q: Does the pipe publish build-info?
A: No. It exports build metadata. Run jf rt bp after collecting artifacts or dependencies. For more information, see Publish Generic Artifacts and Build Information.
Q: Can I use OIDC with the default CLI version?
A: No. Pipe 2.2.0 defaults to CLI 2.56.1. OIDC requires 2.75.0 or later.
Q: Can I download JFrog CLI from my own Artifactory repository?
A: Not with pipe 2.2.0. The setup script uses install-cli.jfrog.io directly.
Q: Why is the setup script gone after source?
source?A: The script deletes itself after setup. This is expected.
Related Topics
Updated 18 days ago
