setup-jfrog-cli
setup-jfrog-cli copied to clipboard
Getting --url option is mandatory error for ping and upload commands
Describe the bug
I'm trying to upload in a GitHub Action with jfrog rt upload --spec build/upload_spec.json
, and I get the --url option is mandatory
error. I tried configuring the JFrog CLI with environment variables (JF_URL and JF_TOKEN), and also with the Config Token exported from my local setup (where the command works).
I tried even just running jfrog rt ping
, and that also gives the same error.
If I add --url on on the command line, the ping command works, but the upload does not (get 401 Unauthorized).
Current behavior
This is the output from the jfrog/setup-jfrog-cli@v3
step
Run jfrog/setup-jfrog-cli@v3
with:
version: [2](https://github.com/REDACTED/actions/runs/4582980103/jobs/8093546472#step:12:2).[3](https://github.com/REDACTED/actions/runs/4582980103/jobs/8093546472#step:12:3)5.0
env:
BRANCH_NAME: 2/merge
CI: true
CHANGE_ID: 2
BUILD_NUMBER: 18
CHANGE_TARGET: master
GITHUB_TOKEN: ***
JFROG_CLI_LOG_LEVEL: DEBUG
AWS_DEFAULT_REGION: us-east-2
AWS_REGION: us-east-2
AWS_ACCESS_KEY_ID: ***
AWS_SECRET_ACCESS_KEY: ***
AWS_SESSION_TOKEN: ***
pythonLocation: /opt/actions-runner/_work/_tool/Python/3.7.16/x6[4](https://github.com/REDACTED/actions/runs/4582980103/jobs/8093546472#step:12:4)
PKG_CONFIG_PATH: /opt/actions-runner/_work/_tool/Python/3.7.16/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/actions-runner/_work/_tool/Python/3.7.16/x64
Python2_ROOT_DIR: /opt/actions-runner/_work/_tool/Python/3.7.16/x64
Python3_ROOT_DIR: /opt/actions-runner/_work/_tool/Python/3.7.16/x64
LD_LIBRARY_PATH: /opt/actions-runner/_work/_tool/Python/3.7.16/x64/lib
JF_ENV_1:
Setup JFrog CLI
Downloading JFrog CLI from https://releases.jfrog.io/artifactory/jfrog-cli/v2/2.3[5](https://github.com/REDACTED/actions/runs/4582980103/jobs/8093546472#step:12:5).0/jfrog-cli-linux-amd[6](https://github.com/REDACTED/actions/runs/4582980103/jobs/8093546472#step:12:6)4/jfrog
This is the out put from my next step, which runs the JFrog CLI command
Run jfrog rt upload --spec build/upload_spec.json
11:56:56 [Debug] JFrog CLI version: 2.35.0
11:56:56 [Debug] OS/Arch: linux/amd64
11:56:56 [Debug] Locking config file to run config Clear command.
11:56:56 [Debug] Creating lock in: /home/ubuntu/.jfrog/locks/config
11:56:56 [Debug] Releasing lock: /home/ubuntu/.jfrog/locks/config/jfrog-cli.conf.lck.5874.1680350216994187067
11:56:56 [Debug] Config Clear command completed successfully. config file is released.
Error: 6 [Error] the --url option is mandatory
Error: Process completed with exit code 1.
When I run the jfrog rt ping
command locally with the JFROG_CLI_LOG_LEVEL="DEBUG" flag set, I see successful HTTP GET commands and 200 responses.
Reproduction steps
I have this in my action:
- name: Setup Jfrog CLI
uses: jfrog/setup-jfrog-cli@v3
env:
JF_ENV_1: ${{ secrets.JF_SECRET_ENV_1 }}
# JF_URL: ${{ secrets.ARTIFACTORY_URL }}
# JF_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }}
- name: Upload to Artifactory
shell: bash
run: jfrog rt upload --spec build/upload_spec.json
When I run the action, the Upload to Artifactory
step fails with the error the --url option is mandatory
. If I add the URL, I get 401 Unauthorized errors (which is the same thing that happens when I run the jfrog rt upload
command locally with that flag). The same thing happens if I run with the Config Token (as shown above in the snip), or with the commented out JF_URL
and JF_ACCESS_TOKEN
env vars instead. I do not try to run with all 3 env vars set.
I created the admin-level access token in the Artifactory UI. We run a self-hosted installation of Artifactory, and do not use JFrog Platform.
Expected behavior
I expect to see something like this
{
"status": "success",
"totals": {
"success": 1,
"failure": 0
}
And find my artifact in Artifactory.
Setup JFrog CLI version
@v3 (as of today, this is 3.2.0)
JFrog CLI version
I'm using the default, which is 2.35.0 as of today.
Workflow operating system type and version
linux/amd64 self-hosted runner, ubuntu-jammy-22.04
JFrog Artifactory version (if relevant)
self-hosted, 7.41.7
JFrog Xray version (if relevant)
N/A
Hi @mackaybeth , Thanks for reporting this issue. Are you sure that you added the secrets correctly on the secrets section under <github_repo_url>/settings/secrets/actions?
JF_ENV_1: ${{ secrets.JF_SECRET_ENV_1 }}
OR
JF_URL: ${{ secrets.ARTIFACTORY_URL }}
JF_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }}
Can you try running an echo command to print the value of secrets.ARTIFACTORY_URL on runtime? Also, can you add the JFROG_CLI_LOG_LEVEL="DEBUG" env to the Action and provide the full logs? It looks like the JFrog CLI is not getting your Credentials and that's why it asks for url.
I also experience this issue in my GitHub pipelines. But it doesn't occur always. Usually after a retry it works. If I enable JFROG_CLI_LOG_LEVEL="DEBUG" I get the following output.
Run jf rt ping 13:55:15 [Debug] JFrog CLI version: 2.50.4 13:55:15 [Debug] OS/Arch: windows/amd64 13:55:15 [Debug] Locking config file to run config Clear command. 13:55:15 [Debug] Creating lock in: C:\windows\ServiceProfiles\NetworkService.jfrog\locks\config 13:55:15 [Debug] Releasing lock: C:\windows\ServiceProfiles\NetworkService.jfrog\locks\config\jfrog-cli.conf.lck.1952.1701348915532607900 13:55:15 [Debug] Config Clear command completed successfully. config file is released. Error: 5 [Error] the --url option is mandatory
@shelling21 It looks like a race condition - the config got cleared before the JFrog CLI read it. Could you please provide an outline of the workflow you used?
I'm curious where the race condition can take place. We use this in a pipeline that performs a hardware-in-the-loop test on a windows host which take about 3-4 minutes to complete. It looks like:
---
name: Hardware in the loop test
on:
workflow_call:
inputs:
buildNumber:
description: GitHub build number
required: true
type: string
configuration:
description: Use a Debug or Release configuration in hil test
required: true
type: string
testTag:
description: Test tag
required: true
type: string
permissions:
contents: read
env:
GIT_COMMIT: ${{ github.sha }}
JFROG_CLI_LOG_LEVEL: DEBUG
jobs:
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false
submodules: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup jfrog-cli
uses: jfrog/setup-jfrog-cli@901bb9632db90821c2d3f076012bdeaf66598555 # v3.4.1
env:
JF_ENV_1: ${{ secrets.ARTIFACTORY_TOKEN }}
- name: Download xxx tool
run: jf rt download generic-external/xxx.exe "xxx.exe"
- name: Download embedded builds
env:
JFROG_CLI_BUILD_NAME: pkgs-embedded+arm-none-eabi
run: jf rt download --build pkgs-embedded+arm-none-eabi/${{ inputs.buildNumber }} "*/(*)/${{ inputs.configuration }}/(*)" "install/{1}/${{ inputs.configuration }}/{2}"
- name: Download tools
env:
JFROG_CLI_BUILD_NAME: pkgs-embedded+i686-w64-mingw32
run: jf rt download --build pkgs-embedded+i686-w64-mingw32/${{ inputs.buildNumber }} "*/(*)/Debug/(*)" "install/tools/{1}/Debug/{2}"
- name: Program device 1
run: |
<Programming commands>
- name: Program device 2
run: |
<Programming commands>
- name: Reset test setup
run: |
<Reset commands>
- name: Sleep for 3 seconds
run: Start-Sleep -s 3
shell: powershell
- name: Run hardware-in-the-loop tests
run: >
<Run hardware-in-the-loop commands>
- name: Upload test report
if: success() || failure()
env:
DEST_PATH: pkgs-embedded-snapshot/nic/${{ github.head_ref || github.ref_name }}/${{ github.run_number }}/
JFROG_CLI_BUILD_NAME: pkgs-embedded+smoke-test-output-${{ inputs.testTag }}
run: |
jf rt ping
jf rt build-collect-env
jf rt upload "integration_test_output/*" "${{ env.DEST_PATH }}"
jf rt build-publish
(I removed the unrelevant parts) Usually the process fails on the jf commands in the last step.
@yahavi : I'm really curious what the problem can be and how to resolve it. Currently our CI/CD pipeline is unstable because of this issue and I would like to fix that.
Hi @shelling21 and @mackaybeth, We believe that the issue was fixed on https://github.com/jfrog/setup-jfrog-cli/releases/tag/v3.4.2 so feel free to update to the latest version. Looking forward to your feedback on it.
Hi @sverdlov93,
I've updated the setup-jfrog-cli action to v3.4.2 but it does not seem to resolve the issue. The same issue happens. The problem seems to be most likely to trigger when there is a longer time between the setup-jfrog-cli action and actually using the jf command in later steps. In our use case we're downloading some binaries with the jf cli, then programming a hw target, run some tests, and then upload the test results to artifactory. Usually the failures are happening in the last upload step. It looks like some token gets expired.
For now I got a workable solution to do a setup-jfrog-cli action before each time I use jf cli. Then when the token seems to get renewed when necessary. If there is already a config with a valid token it passes the action in 0s.
Hi @shelling21 , Are you getting the same debug logs with [Debug] Config Clear command completed successfully. config file is released.
that happens before your last command?
can you share again the full logs?
@sverdlov93: I've sent you the logs via e-mail (from your GitHub profile)
Hi @shelling21 , I see from your logs that you are using an old version of jfrog/setup-jfrog-cli. The latest is v3.5.1 and it should use the version v2.52.7 of JFrog CLI.
On your logs it was:
jfrog/setup-jfrog-cli@901bb9632db90821c2d3f076012bdeaf66598555
with:
version: 2.50.4
I'm running into this today with
- uses: jfrog/setup-jfrog-cli@v4
with:
version: latest
putting jf config show
in the action does show a proper config
@ssplatt , how do you configure the credentials for the task? Can you share the full yaml you use?
here is an example:
- uses: jfrog/setup-jfrog-cli@v4
env:
# JFrog platform url (for example: https://acme.jfrog.io)
JF_URL: ${{ vars.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
Jf_url and jf_access_token as env vars
is there a chance that your env URL is empty? can you add another step before the jfrog-cli step that prints ${{ vars.JF_URL }} to the prompt?