jfrog / jenkins-artifactory-plugin

Jenkins artifactory plugin
http://jenkins-ci.org/
114 stars 187 forks source link

"Username must not be null!" with Gradle in Artifactory plugin version 4.0.0 #905

Closed derekscp closed 9 months ago

derekscp commented 10 months ago

Describe the bug In a previous version of the Artifactory Jenkins plugin (3.18.2) the same build the not fail but as soon as the Artifactory plugin is updated to 4.0.0 you will get a failure with the error "Username must not be null!"

Execution failed for task ':shared:compileJava'.
> Could not resolve all files for configuration ':shared:compileClasspath'.
   > Could not resolve com.google.guava:guava:32.1.2-jre.
     Required by:
         project :shared
      > Could not resolve com.google.guava:guava:32.1.2-jre.
         > Could not get resource 'http://arti.test:8081/artifactory/gradle-libs-release/com/google/guava/guava/32.1.2-jre/guava-32.1.2-jre.pom'.
            > Username must not be null!

It looks like that with the newer 4.0.0 version it does not fall back to the Jenkins Artifactory configuration for resolving but stops at the build.gradle configuration (or wherever you indicated the repository in the repositories block).

Enabling Debug logging I see that in 3.18.2 it first tries the repositories configured in the build.gradle then falls back to the configuration indicated in the pipeline script but in 4.0.0 I don't see any requests to the Artifactory configuration in the Pipeline script.

To Reproduce Here is a sample github project that I tested this on - https://github.com/derekscp/project-examples/tree/master/gradle-examples/gradle-example-publish Here is the pipeline script:

pipeline {
    agent any

    environment {
        DONT_COLLECT = 'FOO'
    }

    stages {
        stage ('Clone') {
            steps {
                git branch: 'master', url: "https://github.com/derekscp/project-examples.git"
            }
        }

        stage ('Artifactory configuration') {
            steps {
                rtGradleDeployer (
                    id: "GRADLE_DEPLOYER",
                    serverId: "httpsderekp-art",
                    releaseRepo: "gradle-libs-snapshot-local",
                    snapshotRepo: "gradle-libs-snapshot-local",
                    excludePatterns: ["*.war"],
                )

                rtGradleResolver (
                    id: "GRADLE_RESOLVER",
                    serverId: "httpsderekp-art",
                    repo: "gradle-libs-release"
                )
            }
        }

        stage ('Config Build Info') {
            steps {
                rtBuildInfo (
                    captureEnv: true,
                    includeEnvPatterns: ["*"],
                    excludeEnvPatterns: ["DONT_COLLECT*"]
                )
            }
        }

        stage ('Exec Gradle') {
            steps {
                sh 'printenv'
                rtGradleRun (
                    usesPlugin: false,
                    useWrapper: true,
                    tool: "GRADLE_TOOL", 
                    rootDir: "gradle-examples/gradle-example-publish/",
                    tasks: "-d clean build test --refresh-dependencies"
                    deployerId: "GRADLE_DEPLOYER",
                    resolverId: "GRADLE_RESOLVER"
                )
            }
        }

        stage ('Publish build info') {
            steps {
                rtPublishBuildInfo (
                    serverId: "httpsderekp-art"
                )
            }
        }
    }
}

Expected behavior I expect it to use the configurations in the pipeline script not just the one from the build.gradle

Versions