Jenkins JFrog Plugin

Run JFrog CLI in Jenkins Pipelines and publish build-info to Artifactory.

The Jenkins JFrog Plugin makes JFrog CLI available as a Jenkins tool and adds the jf Pipeline step. Use it to resolve dependencies, deploy artifacts, scan builds, and publish build-info to JFrog Artifactory without handling credentials in shell commands.

📘

Note

Use this Jenkins JFrog Plugin for new Jenkins Pipelines. The older Jenkins Artifactory Plugin can remain installed while you migrate existing jobs, but do not start new Pipeline DSL on the legacy plugin.

This topic covers the following tasks:

Prerequisites

  • A Jenkins controller and an agent that can run the build.
  • Permission to install and configure Jenkins plugins and tools.
  • A JFrog Platform connection with credentials that can deploy artifacts and publish build-info.
  • Network access to releases.jfrog.io, or a generic remote Artifactory repository that proxies https://releases.jfrog.io/artifactory/jfrog-cli/.
  • A target Artifactory repository. The Quick Start uses my-repo. Replace it with a generic local repository key.
  • Use the same build name and number on jf package or upload commands and jf rt build-publish.

Before You Begin

Confirm repository type. The Quick Start upload uses a generic repository. You also need deploy plus publish-build-info permission and a single build identity. For more information, see How Build Integration Works and Choose Plugin, CLI, or CI Wrapper.

Install and Configure the Plugin

Install the Jenkins JFrog Plugin, then configure a JFrog Platform instance and a JFrog CLI tool on the Jenkins controller.

To install and configure the Jenkins JFrog Plugin:

  1. In Jenkins, install JFrog from Manage Jenkins > Plugins.
  2. Configure a JFrog Platform instance under Manage Jenkins > System.
  3. Under Manage Jenkins > Tools, add a JFrog CLI installation named jfrog-cli.
  4. Choose one installation method:
    • Download automatically from JFrog releases.
    • Download through an Artifactory remote repository. Create a generic remote repository that points to https://releases.jfrog.io/artifactory/jfrog-cli/. The plugin README recommends disabling local artifact storage for this remote.
    • Use a manually installed jf binary.

Quick Start

The following Pipeline verifies the CLI, uploads one file, and publishes build-info.

To run a Quick Start Pipeline:

pipeline {
  agent any
  tools {
    jfrog 'jfrog-cli'
  }
  stages {
    stage('Publish with JFrog') {
      steps {
        sh 'printf "hello from Jenkins\n" > test-file'
        jf '-v'
        jf 'rt ping'
        jf 'rt u test-file my-repo/'
        jf 'rt build-publish'
      }
    }
  }
}

The plugin sets JFROG_CLI_BUILD_NAME, JFROG_CLI_BUILD_NUMBER, and JFROG_CLI_BUILD_URL from the Jenkins job. jf rt build-publish therefore uses the current job name and build number without positional arguments.

Expected result:

  • jf rt ping reports a successful Artifactory connection.
  • test-file is uploaded to my-repo.
  • A build run is published under the Jenkins job name and build number.

What You Should See Next

To confirm that the plugin is working:

  • Open Builds in Artifactory and select the Jenkins job name, then the current Jenkins build number.

Jenkins also adds a build-info action when jf rt bp or jf rt build-publish returns valid build-publish output.

Run JFrog CLI Commands

Use the jf Pipeline step to run any command supported by the installed JFrog CLI.

To run JFrog CLI commands:

  • Use a quoted command string:
jf 'rt u target/ my-repo/'
  • When an argument contains whitespace, use list syntax:
jf(['mvn', 'clean', 'install', '-Ddeploy.testProperty=Property with space'])
  • For Scripted Pipeline, expose the configured tool with:
withEnv(["JFROG_BINARY_PATH=${tool 'jfrog-cli'}"]) {
  jf 'rt ping'
}

The step returns CLI output as a string:

script {
  String version = jf '-v'
  echo version
}

Configure Build Metadata

The plugin supplies these default build identity values unless you override them.

VariableDefault
JFROG_CLI_BUILD_NAMEJenkins JOB_NAME
JFROG_CLI_BUILD_NUMBERJenkins BUILD_NUMBER
JFROG_CLI_BUILD_URLJenkins BUILD_URL

To override the default build identity:

  • Override the name and number in an environment block when you need stable names across jobs.

Use Multiple JFrog Platform Instances

You can pass a configured server ID when a Jenkins controller defines more than one JFrog Platform instance.

To use multiple JFrog Platform instances:

  • Pass the configured server ID with ASCII hyphens.
jf 'rt u test-file my-repo --server-id=server-1'

Configure Jenkins as Code

The plugin supports Jenkins Configuration as Code for JFrog Platform instances and JFrog CLI tool installations.

To configure Jenkins as Code:

  • Keep credentials in Jenkins Credentials and reference the credential ID from the instance configuration.
  • Use the plugin repository's current README as the source for the complete schema because fields can change between plugin releases.

Use Freestyle Jobs

The plugin also provides a Run JFrog CLI build step.

To make jf available in Freestyle shell steps:

  • Use the plugin's build-environment wrapper so the configured binary is available to subsequent build steps.

Advanced CLI Flows

The jf step accepts any command supported by the installed JFrog CLI. Common flows include:

  • jf mvn-config followed by jf mvn
  • jf gradle-config followed by jf gradle
  • jf npm-config followed by jf npm
  • jf go-config followed by jf go
  • jf docker push
  • jf rt build-publish

You can validate options against jf <command> --help on the Jenkins agent, especially when you pin a CLI version.

Troubleshooting

The following table lists common problems and their resolutions.

What You SeeCauseWhat To Do
No such DSL method 'jf'The plugin is absent, disabled, or an old job uses a different plugin.Install or enable Jenkins JFrog Plugin and restart Jenkins if required.
JFrog CLI is unavailableThe Pipeline did not declare the configured tool, or the tool name differs.Match the name in tools { jfrog 'jfrog-cli' } to Manage Jenkins > Tools.
CLI download failsThe agent cannot reach JFrog releases.Configure the Artifactory installation source or install jf manually.
Upload returns 401/403Credentials lack deploy permission.Check the Jenkins credential and repository permissions.
Build is missing in Artifactoryjf rt build-publish did not run or failed.Run publish after commands that collect artifacts and dependencies.
Arguments split incorrectlyA value contains spaces.Use list syntax instead of a single command string.
Upgrade is skipped on WindowsAnother process is using the CLI binary.Let the build use the installed version. The plugin retries the upgrade on a later build.

Migrate from Jenkins Artifactory Plugin

Install both plugins side by side while you migrate. Recreate legacy build steps as explicit jf commands, verify repository resolution and deployment, publish build-info, and compare the resulting build before retiring each legacy job.

To migrate from the Jenkins Artifactory Plugin:

Related Topics


Did this page help you?