Build Integration
Overview
JFrog CLI integrates with any development ecosystem allowing you to collect build-info and then publish it to Artifactory. By publishing build-info to Artifactory, JFrog CLI empowers Artifactory to provide visibility into artifacts deployed, dependencies used and extensive information on the build environment to allow fully traceable builds. Read more about build-info and build integration with Artifactory here.
Many of JFrog CLI's commands accept two optional command options: --build-name and --build-number. When these options are added, JFrog CLI collects and records the build info locally for these commands. When running multiple commands using the same build and build number, JFrog CLI aggregates the collected build info into one build. The recorded build-info can be later published to Artifactory using the build-publish command.
Collecting Build-Info
Build-info is collected by adding the --build-name
and --build-number
options to different CLI commands. The CLI commands can be run several times and cumulatively collect build-info for the specified build name and number until it is published to Artifactory. For example, running the jf rt download
command several times with the same build name and number will accumulate each downloaded file in the corresponding build-info.
Collecting Dependencies
Dependencies are collected by adding the --build-name
and --build-number
options to the jf rt download
command.
For example, the following command downloads the cool-froggy.zip
file found in repository my-local-repo
, but it also specifies this file as a dependency in build my-build-name
with build number 18:
Collecting Build Artifacts
Build artifacts are collected by adding the --build-name
and --build-number
options to the jf rt upload
command.
For example, the following command specifies that file froggy.tgz
uploaded to repository my-local-repo
is a build artifact of build my-build-name
with build number 18:
Collecting Environment Variables
This command is used to collect environment variables and attach them to a build.
Environment variables are collected using the build-collect-env
(bce
) command.
Usage
jf rt bce <build name> <build number>
Commands Params
The following table lists the command arguments and flags:
Examples
Example 1
The following command collects all currently known environment variables, and attaches them to the build-info for build my-build-name
with build number 18:
Example 2
Collect environment variables for build name: frogger-build and build number: 17
Collecting Information from Git
The build-add-git
(bag) command collects the Git revision and URL from the local .git directory and adds it to the build-info. It can also collect the list of tracked project issues (for example, issues stored in JIRA or other bug tracking systems) and add them to the build-info. The issues are collected by reading the git commit messages from the local git log. Each commit message is matched against a pre-configured regular expression, which retrieves the issue ID and issue summary. The information required for collecting the issues is retrieved from a yaml configuration file provided to the command.
Usage
jf rt bag [command options] <build name> <build number> [Path To .git]
Commands Params
The following table lists the command arguments and flags:
Configuration file properties
Example
This is the configuration file structure.
Adding Files as Build Dependencies
The download command, as well as other commands which download dependencies from Artifactory accept the --build-name and --build-number command options. Adding these options records the downloaded files as build dependencies. In some cases however, it is necessary to add a file, which has been downloaded by another tool, to a build. Use the build-add-dependencies command to this.
By default, the command collects the files from the local file system. If you'd like the files to be collected from Artifactory however, add the --from-rt option to the command.
Usage
jf rt bad [command options] <build name> <build number> <pattern>
jf rt bad --spec=<File Spec path> [command options] <build name> <build number>
Commands Params
Examples
Example 1
Add all files located under the path/to/build/dependencies/dir directory as dependencies of a build. The build name is my-build-name and the build number is 7. The build-info is only updated locally. To publish the build-info to Artifactory use the jf rt build-publish command.
Example 2
Add all files located in the m-local-repo Artifactory repository, under the dependencies folder, as dependencies of a build. The build name is my-build-name and the build number is 7. The build-info is only updated locally. To publish the build-info to Artifactory use the jf rt build-publish command.
Example 3
Add all files located under the path/to/build/dependencies/dir directory as dependencies of a build. The build name is my-build-name, the build number is 7 and module is m1. The build-info is only updated locally. To publish the build-info to Artifactory use the jf rt build-publish command.
Publishing Build-Info
This command is used to publish build info to Artifactory. To publish the accumulated build-info for a build to Artifactory, use the build-publish command. For example, the following command publishes all the build-info collected for build my-build-name with build number 18:
Usage
jf rt bp [command options] <build name> <build number>
Commands Params
Example
Publishes to Artifactory all the build-info collected for build my-build-name with build number 18
Aggregating Published Builds
The build-info, which is collected and published to Artifactory by the jf rt build-publish command, can include multiple modules. Each module in the build-info represents a package, which is the result of a single build step, or in other words, a JFrog CLI command execution. For example, the following command adds a module named m1 to a build named my-build with 1 as the build number:
The following command, adds a second module, named m2 to the same build:
You now publish the generated build-info to Artifactory using the following command:
Now that you have your build-info published to Artifactory, you can perform actions on the entire build. For example, you can download, copy, move or delete all or some of the artifacts of a build. Here's how you do this.
In some cases though, your build is composed of multiple build steps, which are running on multiple different machines or spread across different time periods. How do you aggregate those build steps, or in other words, aggregate those command executions, into one build-info?
The way to do this, is to create a separate build-info for every section of the build, and publish it independently to Artifactory. Once all the build-info instances are published, you can create a new build-info, which references all the previously published build-info instances. The new build-info can be viewed as a "master" build-info, which references other build-info instances.
So the next question is - how can this reference between the two build-instances be created?
The way to do this is by using the build-append command. Running this command on an unpublished build-info, adds a reference to a different build-info, which has already been published to Artifactory. This reference is represented by a new module in the new build-info. The ID of this module will have the following format: **<referenced build name>/<referenced build number>.
Now, when downloading the artifacts of the "master" build, you'll actually be downloading the artifacts of all of its referenced builds. The examples below demonstrates this,
Usage
jf rt ba <build name> <build number> <build name to append> <build number to append>
Commands Params
Requirements
Artifactory version 7.25.4 and above.
Example
This script illustrates the process of creating two build-info instances, publishing both to Artifactory, and subsequently generating a third build-info that consolidates the published instances before publishing it to Artifactory.
Promoting a Build
This command is used to promote build in Artifactory.
Usage
jf rt bpr [command options] <build name> <build number> <target repository>
Commands Params
Example
This example involves moving the artifacts associated with the published build-info, identified by the build name 'my-build-name' and build number '18', from their existing Artifactory repository to a new Artifactory repository called 'target-repository'.
Cleaning up the Build
Build-info is accumulated by the CLI according to the commands you apply until you publish the build-info to Artifactory. If, for any reason, you wish to "reset" the build-info and cleanup (i.e. delete) any information accumulated so far, you can use the build-clean
(bc
) command.
Usage
jf rt bc <build name> <build number>
Commands Params
The following table lists the command arguments and flags:
Example
The following command cleans up any build-info collected for build my-build-name
with build number 18:
Discarding Old Builds from Artifactory
This command is used to discard builds previously published to Artifactory using the build-publish command.
Usage
jf rt bdi [command options] <build name>
Commands Params
The following table lists the command arguments and flags:
Examples
Example 1
Discard the oldest build numbers of build my-build-name from Artifactory, leaving only the 10 most recent builds.
Example 2
Discard the oldest build numbers of build my-build-name from Artifactory, leaving only builds published during the last 7 days.
Example 3
Discard the oldest build numbers of build my-build-name from Artifactory, leaving only builds published during the last 7 days. b20 and b21 will not be discarded.
Last updated