jfrog / jfrog-cli

JFrog CLI is a client that provides a simple interface that automates access to the JFrog products.
https://www.jfrog.com/confluence/display/CLI/JFrog+CLI
Apache License 2.0
531 stars 230 forks source link

jf rt build-discard isn't sensitive to the the JFROG_CLI_BUILD_PROJECT environment variable #2038

Open enaess opened 1 year ago

enaess commented 1 year ago

Describe the bug

In an Jenkins pipeline, I specify my environment variables such as:

Then I run the jf rt bdi --max-builds 30 --delete-artifacts at the end of my pipeline.

Current behavior

When I run the jf rt bdi command, it doesn't appear that it actually discarded any builds.

Reproduction steps

12:56:08 [Debug] JFrog CLI version: 2.40.0
12:56:08 [Debug] OS/Arch: linux/amd64
12:56:08 [Debug] Usage Report: Sending info...
12:56:09 [🔵Info] Discarding builds...
12:56:09 [Debug] Sending HTTP POST request to: https://artifactory/artifactory/api/build/retention/MyProject?async=false
12:56:09 [Debug] Sending HTTP GET request to: https://artifactory/artifactory/api/system/version
12:56:09 [Debug] Artifactory response: 200 
12:56:09 [Debug] JFrog Artifactory version is: 7.41.14
12:56:09 [Debug] Sending HTTP POST request to: https://artifactory/artifactory/api/system/usage
12:56:09 [🔵Info] Builds discarded.
12:56:09 [Debug] Usage Report: Usage info sent successfully. Artifactory response: 200 

Next is the working case where I specify the --project parameter on the command line:

12:57:47 [Debug] JFrog CLI version: 2.40.0
12:57:47 [Debug] OS/Arch: linux/amd64
12:57:47 [Debug] Usage Report: Sending info...
12:57:47 [🔵Info] Discarding builds...
12:57:47 [Debug] Sending HTTP POST request to: https://artifactory/artifactory/api/build/retention/MyProject?async=false&project=my-project
12:57:47 [Debug] Sending HTTP GET request to: https://artifactory/artifactory/api/system/version
12:57:47 [Debug] Artifactory response: 200 
12:57:47 [Debug] JFrog Artifactory version is: 7.41.14
12:57:47 [Debug] Sending HTTP POST request to: https://artifactory/artifactory/api/system/usage
12:57:47 [Debug] Usage Report: Usage info sent successfully. Artifactory response: 200 

Notice the presence of the project= parameter to the REST API in my second attempt. It seems to be missing when I specify the JFROG_CLI_BUILD_PROJECT environment variable (and omit the --project parameter).

Expected behavior

I should be able to export the JFROG_CLI_BUILD_PROJECT into the environment and have it be used in place of the --project parameter to the jf command like many other commands

JFrog CLI version

2.40.0

Operating system type and version

Ubuntu 22.04

JFrog Artifactory version

7.41.14

JFrog Xray version

No response

RobiNino commented 1 year ago

Hi @enaess , Thank you for reporting this. JFrog CLI 2.44.0 includes a fix to this issue, feel free to upgrade. We would appreciate your feedback for it.