• Stars
    star
    230
  • Rank 168,359 (Top 4 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Set up JFrog CLI in your GitHub Actions workflow

JFrog CLI

Setup JFrog CLI

Scanned by Frogbot Build status

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. Read more about it here.
  • 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

- uses: jfrog/setup-jfrog-cli@v3
- run: jf --version

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.

  1. Storing the connection details using separate environment variables.
  2. Storing the connection details using single Config Token.

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:

  1. JF_URL (no authentication)
  2. JF_URL + JF_USER + JF_PASSWORD (basic authentication)
  3. JF_URL + JF_ACCESS_TOKEN (authentication using a JFrog Access Token)

You can use these environment variables in your workflow as follows:

- uses: jfrog/setup-jfrog-cli@v3
  env:
    # JFrog platform url (for example: https://acme.jfrog.io) 
    JF_URL: ${{ secrets.JF_URL }}
    
    # Basic authentication credentials
    JF_USER: ${{ secrets.JF_USER }}
    JF_PASSWORD: ${{ secrets.JF_PASSWORD }}
    or
    # JFrog Platform access token
    JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
- run: |
    jf rt ping
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 jf c use setup-jfrog-cli-server

Storing the connection details using single Config Token

  1. Make sure JFrog CLI is installed on your local machine by running jf -v.
  2. Configure the details of the JFrog platform by running jf c add.
  3. Export the details of the JFrog platform you configured, using the server ID you chose. Do this by running jf c export <SERVER ID>.
  4. 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:

- uses: jfrog/setup-jfrog-cli@v3
  env:
    JF_ENV_1: ${{ secrets.JF_SECRET_ENV_1 }}
- run: |
    # Ping the server
    jf rt ping

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:

- uses: jfrog/setup-jfrog-cli@v3
  env:
    JF_ENV_1: ${{ secrets.JF_SECRET_ENV_1 }}
    JF_ENV_2: ${{ secrets.JF_SECRET_ENV_2 }}
- run: |
    # Set the JFrog configuration to use by providing the server ID (configured by the 'jf c add' command).
    jf c use local-1
    # Ping local-1 Artifactory server
    jf rt ping
    # Now use the second sever configuration exposed to the Action.
    jf c use local-2
    # Ping local-2 Artifactory server
    jf rt ping
Important: When exposing more than one JFrog configuration to the Action, you should always add the jf c use command to specify the server to use.

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.

- run: |
    jf rt dl artifacts/
    jf rt u aether artifacts/
    jf rt bp

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:

- uses: jfrog/setup-jfrog-cli@v3
  with:
    version: X.Y.Z

It is also possible to set the latest JFrog CLI version by adding the version input as follows:

- uses: jfrog/setup-jfrog-cli@v3
  with:
    version: latest
Important: Only JFrog CLI versions 1.29.0 or above are supported.

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.

Here's how you do this:

  1. Create a remote repository in Artifactory. Name the repository jfrog-cli-remote and set its URL to https://releases.jfrog.io/artifactory/jfrog-cli/
  2. Set download-repository input to jfrog-cli-remote:
    - uses: jfrog/setup-jfrog-cli@v3
      env:
       # JFrog platform url (for example: https://acme.jfrog.io) 
        JF_URL: ${{ secrets.JF_URL }}
    
        # Basic authentication credentials
        JF_USER: ${{ secrets.JF_USER }}
        JF_PASSWORD: ${{ secrets.JF_PASSWORD }}
    
        # JFrog platform access token (if JF_USER and JF_PASSWORD are not provided)
        # JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
    
        # Same can be achieved with a Config Token using JF_ENV_1 environment variable
        # JF_ENV_1: ${{ secrets.JF_SECRET_ENV_1 }}
      with:
        download-repository: jfrog-cli-remote

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:

  1. Install JFrog CLI on your machine.
  2. Create a FREE JFrog environment in the cloud for you.

MacOS and Linux using cUrl

curl -fL "https://getcli.jfrog.io?setup" | sh

Windows using PowerShell

powershell "Start-Process -Wait -Verb RunAs powershell '-NoProfile iwr https://releases.jfrog.io/artifactory/jfrog-cli/v2-jf/[RELEASE]/jfrog-cli-windows-amd64/jf.exe -OutFile $env:SYSTEMROOT\system32\jf.exe'" ; jf setup

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

npm i && npm t

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

More Repositories

1

project-examples

Small projects in universal build ecosystems to configure CI and Artifactory
C#
974
star
2

jfrog-cli

JFrog CLI is a client that provides a simple interface that automates access to the JFrog products.
Go
513
star
3

artifactory-user-plugins

Sample Artifactory User Plugins
Groovy
356
star
4

artifactory-docker-examples

Examples for using Artifactory Docker distribution in various environments
Shell
331
star
5

artifactory-client-java

Artifactory REST Client Java API bindings
Java
315
star
6

frogbot

🐸 Scans your Git repository with JFrog Xray for security vulnerabilities. πŸ€–
Go
277
star
7

terraform-provider-artifactory

Terraform provider to manage JFrog Artifactory
Go
271
star
8

charts

JFrog official Helm Charts
Shell
247
star
9

jfrog-client-go

All go clients for JFrog products
Go
211
star
10

log4j-tools

Java
169
star
11

gocenter

The Github README for JFrog Go-center. Use this for reporting issues
164
star
12

jfrog-idea-plugin

JFrog IntelliJ IDEA plugin
Java
153
star
13

jfrog-vscode-extension

JFrog VS-Code Extension
TypeScript
151
star
14

terraform-provider-project

Terraform provider to manage JFrog Projects
Go
147
star
15

build-info

Artifactory's open integration layer for CI build servers
Java
146
star
16

terraform-provider-xray

Terraform provider to manage JFrog Xray
Go
145
star
17

artifactory-scripts

Scripts for Artifactory (Usually, for REST API), community driven.
Groovy
143
star
18

text4shell-tools

Python
105
star
19

jfrog-spring-tools

Python
84
star
20

JFrog-Cloud-Installers

Template to deploy Artifactory Enterprise cluster.
CSS
78
star
21

jfrog-docker-desktop-extension

🐸 Scans any of your local Docker images for security vulnerabilities. πŸ‹
TypeScript
74
star
22

nexus2artifactory

NexusToArtifactory - A tool designed to ease migration from Sonatype Nexus to JFrog Artifactory.
Python
67
star
23

nimbuspwn-tools

Shell
65
star
24

build-info-go

build-info-go is a Go library and a CLI, which allows generating build-info for a source code project.
Go
56
star
25

cocoapods-art

CocoaPods Plugin to work against Artifactory Repository
Ruby
53
star
26

jfrog-cli-plugins-reg

Go
52
star
27

jfrog-npm-tools

Python
52
star
28

kubenab

Kubernetes Admission Webhook to enforce pulling of Docker images from the private registry.
Go
46
star
29

jfrog-CVE-2023-25136-OpenSSH_Double-Free

Python
43
star
30

teamcity-artifactory-plugin

TeamCity plugin that enables traceable build artifacts with Artifactory
Java
42
star
31

froggit-go

Froggit-Go is a universal Go library, allowing to perform actions on VCS providers.
Go
42
star
32

jfrog-azure-devops-extension

JavaScript
41
star
33

chartcenter

The Central Helm Repository for the Community
Dockerfile
41
star
34

jfrog-CVE-2022-21449

Python
40
star
35

bamboo-artifactory-plugin

Atlassian Bamboo plugin that enables traceable build artifacts with Artifactory
Java
40
star
36

jfrog-docker-repo-simple-example

Getting started with JFrog Docker Repos - Example
Dockerfile
39
star
37

vault-plugin-secrets-artifactory

HashiCorp Vault Secrets Plugin for Artifactory
Go
38
star
38

artifactory-cli-go

Artifactory CLI written in Golang
Go
33
star
39

jfrog-cli-core

Go
32
star
40

docker2artifactory

Python
29
star
41

mlflow-jfrog-plugin

Python
27
star
42

artifactory-docker-builder

Groovy
27
star
43

gitlab-templates

Templates for CI/CD in GitLab using JFrog CLI
26
star
44

auto-mat

A docker container to generate heap dump reports and indexes for eclipse MAT
Java
25
star
45

kubexray

JFrog KubeXray scanner on Kubernetes
Go
25
star
46

log-analytics-prometheus

JFrog Prometheus Log Analytics Integration
23
star
47

artifactory-maven-plugin

A Maven plugin to resolve artifacts from Artifactory, deploy artifacts to Artifactory, capture and publish build info.
Java
23
star
48

cve-2024-3094-tools

Shell
21
star
49

polkit-tools

Shell
18
star
50

jfrog-registry-operator

Enhancing AWS Security: JFrog's Seamless Integration and the Power of AssumeRole
Go
18
star
51

jfrog-cli-plugins

Go
17
star
52

artifactory-gradle-plugin

JFrog Gradle plugin for Build Info extraction and Artifactory publishing.
Java
17
star
53

log-analytics

JFrog Log Analytics
Shell
17
star
54

gofrog

A collection of go utilities
Go
15
star
55

bower-art-resolver

JavaScript
15
star
56

jfrog-openssl-tools

Python
14
star
57

gradle-dep-tree

Gradle plugin that reads the Gradle dependencies of a given Gradle project, and generates a dependency tree.
Java
13
star
58

DevRel

Java
12
star
59

artifactory-sbt-plugin

The SBT Plugin for Artifactory resolve and pulish
Scala
12
star
60

artifactory-user-plugins-devenv

Development Environment for writting Artifactory User Plugins
Shell
12
star
61

aws-codestar

Artifactory-Code Star integration
Shell
12
star
62

SwampUp2022

Shell
12
star
63

jfrog-client-js

Xray Javascript Client
TypeScript
11
star
64

maven-anno-mojo

Write Maven plugins using annotations
Java
11
star
65

jfrog-ecosystem-integration-env

A Docker image containing all the tools JFrog CLI integrates with and supports.
Dockerfile
11
star
66

bamboo-jfrog-plugin

Easy integration between Bamboo and the JFrog Platform.
Java
10
star
67

xray-client-java

Xray Java Client
Java
9
star
68

artifactory-bosh-release

Bosh release of Artifactory for the PCF
HTML
9
star
69

msbuild-artifactory-plugin

Artifactory integration with MSBuild
C#
8
star
70

jfrog-ide-webview

JFrog-IDE-Webview is a React-based HTML page designed to be seamlessly embedded within JFrog VS Code Extension and the JFrog IDEA Plugin.
TypeScript
8
star
71

docker-compose-demos

JFrog example demos using docker compose
Shell
8
star
72

jfrog-visual-studio-extension

C#
8
star
73

log-analytics-elastic

JFrog Elastic Fluentd Kibana Log Analytics Integration
8
star
74

jfrog-ui-essentials

JavaScript
8
star
75

go-mockhttp

Go
7
star
76

ide-plugins-common

Common code used by the JFrog Idea Plugin and the JFrog Eclipse plugin
Java
7
star
77

jfrog-pipelines-task

7
star
78

nuget-deps-tree

This npm package reads the NuGet dependencies of a .NET project, and generates a dependencies tree object.
TypeScript
7
star
79

knife-art

Knife Artifactory integration
Ruby
7
star
80

jfrog-pipelines-go-task

Makefile
7
star
81

jfrog-mission-control-2.0

Jfrog Mission Control 2.0 example scripts
Groovy
7
star
82

log-analytics-splunk

JFrog Splunk Log Analytics Integration
JavaScript
6
star
83

go-license-discovery

A go library for matching text against known OSS licenses
Go
6
star
84

npm_domain_check

Python
6
star
85

jfrog-cli-plugin-template

Go
6
star
86

jfrog-distroless

Starlark
6
star
87

terraform-provider-pipeline

Terraform provider to manage Artifactory Pipelines
Go
6
star
88

docker-remote-util

A groovy util library to interact with docker remote api
Groovy
6
star
89

webapp-examples

Examples of Web Application that use Artifactory as a backend
CSS
6
star
90

jfrog-pipelines-jenkins-example

Go
5
star
91

maven-dep-tree

Maven plugin that reads the Maven dependencies of a given Maven project, and generates a dependency tree.
Java
5
star
92

log-analytics-datadog

JFrog Datadog Log Analytics Integration
Dockerfile
5
star
93

jfrog-apps-config

The configuration file allows you to refine your JFrog Advanced Security scans behavior according to your specific project needs and structures, leading to better and more accurate scan results.
Go
5
star
94

fan4idea

Java
4
star
95

live-logs

Go
4
star
96

gocmd

Go
4
star
97

jfrog-pipelines-docker-sample

Shell
4
star
98

SwampUp2023

HCL
4
star
99

jfrog-testing-infra

Common testing code used by integration tests of Jenkins and Bamboo Artifactory plugins.
Java
4
star
100

wharf

Wharf resolver
Java
4
star