jfrog / jenkins-jfrog-plugin

Easy integration between Jenkins and the JFrog Platform.
https://github.com/jfrog/jenkins-jfrog-plugin
Apache License 2.0
39 stars 17 forks source link

jf rt bdi doesn't include value of JFROG_CLI_BUILD_RROJECT=" ... " #72

Closed enaess closed 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.


withEnv(["JFROG_CLI_BUILD_NAME='build-name'", 
        ["JFROG_CLI_BUILD_PROJECT='myproject']) {

    jf rt build-publish ..
    jf rt build-discard --max-build 30 --delete artifacts
}

Current behavior

When I go looking in AF, I have plenty more builds than the last 30...

Trying the same thing from command line and posting the output. The following is the non-working case where JFROG_CLI_BUILD_PROJECT is set in the environment:

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

Reproduction steps

See above

Expected behavior

My builds should be discarded and the correct project as specified by the JF_CLI_BUILD_PROJECT environment variable should be passed along to the REST call.

JFrog plugin version

1.4.0

JFrog CLI version

2.40.0

Operating system type and version

Ubuntu 22.04

JFrog Artifactory version

No response

JFrog Xray version

No response

enaess commented 1 year ago

Figured this is posted to the wrong project. Opened an issue on jfrog-cli project instead. https://github.com/jfrog/jfrog-cli/issues/2038