jfrog-cli icon indicating copy to clipboard operation
jfrog-cli copied to clipboard

Allow executing Gradle from GRADLE_HOME and not just via path

Open enaess opened this issue 10 months ago • 0 comments

Describe the bug

I have a Jenkins pipeline script where I want to execute jf gradle .... The stage is executed by a docker agent. However, with Jenkins' tooling for Gradle (e.g. tools name: "gradle-8.5", type "gradle" will install the tool into /home//tool and add it to the path.

Current behavior

However, because the PATH is not passed onto the docker container doing the build (nor should it), the jf gradle command fails with command not found i.e. gradle is not on the path.

Reproduction steps

pipeline {
    agent {
        docker {
            label "linux"
            image "android-builder:jammy-20250127"
            args "--mount type=bind,src=$home/tools,dst=$home/tools
        }
    }
    stages {
        stage("Build") {
            tools {
                jfrog 'jfrog-cli'
                gradle 'gradle-8.8'
            }
            environment {
                GRADLE_HOME = tool name: 'gradle-8.8', type: gradle
            }
            steps {
                script {
                    jf 'config use myartifactory'
                    jf 'rt ping'
                    jf 'gradle clean artifactoryPublish' // command fails as PATH is incorrect (missing e.g. PATH=$PATH:$GRADLE_HOME)
                }
            }
        }
    }
}

Expected behavior

jfrog-cli should be aware of GRADLE_HOME and execute $GRADLE_HOME/bin/gradle if $GRADLE_HOME is found in the environment, otherwise fallback to using the PATH. Or maybe allow the user a command line option to specify the gradle executable??

Note that the jf plugin seems quite capable of locating the jf executable set in the environment as: JFROG_BINARY_PATH=/home/<user>/tools/io.jenkins.plugins.jfrog.JfrogInstallation/jfrog-cli

JFrog CLI version

2.73.2

Operating system type and version

linux

JFrog Artifactory version

N/A

JFrog Xray version

N/A

enaess avatar Jan 31 '25 19:01 enaess