GitHub Actions
Setup JFrog CLI
This GitHub Action downloads, installs and configures JFrog CLI, so that it can be used as part of the workflow.
In addition, the Action includes the following features, when using JFrog CLI to work with JFrog Platform.
The connection details of the JFrog platform used by JFrog CLI can be stored as secrets.
There's no need to add the build name and build number options and arguments to commands which accept them. All build related operations will be automatically recorded with the Workflow Name as build name and Run Number as build number.
Usage
General
Storing JFrog connection details as secrets
The connection details of the JFrog platform used by JFrog CLI can be stored as secrets. You can use one of the following two methods to define and store the JFrog Platform connection details as secrets.
Storing the connection details using separate environment variables
You can set the connection details to your JFrog Platform by using one of the following environment variables combinations:
JF_URL (no authentication)
JF_URL + JF_USER + JF_PASSWORD (basic authentication)
JF_URL + JF_ACCESS_TOKEN (authentication using a JFrog Access Token)
You can use these environment variables in your workflow as follows:
Important: If both Config Token(JF_ENV_*) and separate environment variables(JF_URL, ...) are provided, the default config will be the Config Token. To make the above separate environment variables as the default config use |
Storing the connection details using single Config Token
Make sure JFrog CLI is installed on your local machine by running
jf -v
.Configure the details of the JFrog platform by running
jf c add
.Export the details of the JFrog platform you configured, using the server ID you chose. Do this by running
jf c export <SERVER ID>
.Copy the generated Config Token to the clipboard and save it as a secret on GitHub.
To use the saved JFrog platform configuration in the workflow, all you need to do it to expose the secret to the workflow. The secret should be exposed as an environment variable with the JF_ENV_ prefix. Here's how you do this:
As you can see in the example above, we created a secret named JF_SECRET_ENV_1 and exposed it to the workflow as the JF_ENV_1 environment variable. That's it - the ping command will now ping the configured Artifactory server.
If you have multiple Config Tokens as secrets, you can use all of them in the workflow as follows:
Important: When exposing more than one JFrog configuration to the Action, you should always add the |
Setting the build name and build number when publishing build-info to Artifactory
The Action automatically sets the following environment variables: JFROG_CLI_BUILD_NAME and JFROG_CLI_BUILD_NUMBER with the workflow name and run number respectively. You therefore don't need to specify the build name and build number on any of the build related JFrog CLI commands.
In the following example, all downloaded files are registered as dependencies of the build and all uploaded files are registered as the build artifacts.
Setting JFrog CLI version
By default, the JFrog CLI version set in action.yml is used. To set a specific version, add the version input as follows:
It is also possible to set the latest JFrog CLI version by adding the version input as follows:
Downloading JFrog CLI from Artifactory
If your agent has no Internet access, you can configure the workflow to download JFrog CLI from a remote repository in your JFrog Artifactory, which is configured to proxy the official download URL. When creating the remote repository, select the Generic package type for the repository.
Here's how you do this:
Create a remote repository in Artifactory. Name the repository jfrog-cli-remote and set its URL to https://releases.jfrog.io/artifactory/jfrog-cli/
Set download-repository input to jfrog-cli-remote:
See instructions for configuring the JFrog connection details under Storing JFrog connection details as secrets.
Set up a FREE JFrog Environment in the Cloud
Need a FREE JFrog environment in the cloud to use with this GitHub Action? Just run one of the following commands in your terminal. The commands will do the following:
Install JFrog CLI on your machine.
Create a FREE JFrog environment in the cloud for you.
MacOS and Linux using cUrl
Windows using PowerShell
Example projects
To help you get started, you can use these sample projects on GitHub.
Developing the Action code
Build the code
If you'd like to help us develop and enhance this Action, this section is for you.
To build and run the Action tests, run
Code contributions
We welcome code contributions through pull requests.
Please help us enhance and improve this Action.
Pull requests guidelines
If the existing tests do not already cover your changes, please add tests.
Please run
npm run format
for formatting the code before submitting the pull request.
License
This Action is licensed under the Apache License 2.0.
References
Last updated