Details
-
Bug
-
Status: Reopened (View Workflow)
-
Blocker
-
Resolution: Unresolved
-
None
-
config-file-provider-plugin 3.5
pipeline-maven-plugin 3.8.1
credentials-plugin 2.1.19
Description
hard coding "<servers></servers>" in the config file works but configuring "Server Credentials" from jenkins credentials is not working. I tried with and without "Replace all"
Attachments
Activity
I've also tried all three variations with "Replace All" enabled and disabled. It had no discernable difference on the outcome.
FYI, I just tried again with only "Default settings provider" specified in the Global Tools Configuration and the log output indicates that it found no settings at all. This leads me to believe my interpretation of the plugin documentation is correct and it does not pull in "Default settings provider" from Global Tools Configuration at all. Only "global settings provider".
I believe this is somehow related to JENKINS-43651. Note the slightly larger logged information when this doesn't work:
[Pipeline] { [Pipeline] withMaven [2022-01-17T15:04:43.074Z] [withMaven] Options: [] [2022-01-17T15:04:43.081Z] [withMaven] Available options: [2022-01-17T15:04:43.081Z] [withMaven] using JDK installation provided by the build agent [2022-01-17T15:04:44.027Z] [withMaven] using Maven global settings.xml 'global-maven-settings' with Maven servers credentials provided by Jenkins (replaceAll: false): [mavenServerId: 'com.mycompany.repo.releases', jenkinsCredentials: '7ad2488b-6087-4727-a1ca-6b9ced57baa6', username: 'ci', type: 'UsernamePasswordCredentialsImpl'], [mavenServerId: 'com.mycompany.repo.snapshots', jenkinsCredentials: '7ad2488b-6087-4727-a1ca-6b9ced57baa6', username: 'ci', type: 'UsernamePasswordCredentialsImpl'] [2022-01-17T15:04:44.036Z] $ /bin/sh -c "which mvn" [2022-01-17T15:04:44.050Z] [withMaven] Maven installation not specified in the 'withMaven()' step and not found on the build agent but 'mvnw' script found in the workspace. [Pipeline] { [Pipeline] sh [2022-01-17T15:04:44.438Z] + mvn help:effective-settings [2022-01-17T15:04:44.438Z] Picked up JAVA_TOOL_OPTIONS: -Dmaven.ext.class.path="/var/lib/jenkins/workspace/NL_log-client-java_PR-25@tmp/withMaven4d6d91f7/pipeline-maven-spy.jar" -Dorg.jenkinsci.plugins.pipeline.maven.reportsFolder="/var/lib/jenkins/workspace/NL_log-client-java_PR-25@tmp/withMaven4d6d91f7" [2022-01-17T15:04:46.922Z] [INFO] [jenkins-event-spy] Generate /var/lib/jenkins/workspace/NL_log-client-java_PR-25@tmp/withMaven4d6d91f7/maven-spy-20220117-150446-38215226537671442746533.log.tmp ... [2022-01-17T15:04:46.922Z] [INFO] Scanning for projects... [2022-01-17T15:04:47.472Z] [INFO] [2022-01-17T15:04:47.473Z] [INFO] ------------------< com.mycompany.ncp:log-client-java >------------------- [2022-01-17T15:04:47.473Z] [INFO] Building Log Client for Java 1.2.1-SNAPSHOT [2022-01-17T15:04:47.473Z] [INFO] --------------------------------[ jar ]--------------------------------- [2022-01-17T15:04:47.473Z] [INFO] [2022-01-17T15:04:47.473Z] [INFO] --- maven-help-plugin:3.2.0:effective-settings (default-cli) @ log-client-java --- [2022-01-17T15:04:48.816Z] [INFO] [2022-01-17T15:04:48.816Z] Effective user-specific configuration settings: [2022-01-17T15:04:48.816Z] [2022-01-17T15:04:48.816Z] <?xml version="1.0" encoding="UTF-8"?> [2022-01-17T15:04:48.816Z] <!-- ====================================================================== --> [2022-01-17T15:04:48.816Z] <!-- --> [2022-01-17T15:04:48.816Z] <!-- Generated by Maven Help Plugin on 2022-01-17T15:04:48Z --> [2022-01-17T15:04:48.816Z] <!-- See: http://maven.apache.org/plugins/maven-help-plugin/ --> [2022-01-17T15:04:48.816Z] <!-- --> [2022-01-17T15:04:48.816Z] <!-- ====================================================================== --> [2022-01-17T15:04:48.816Z] <!-- ====================================================================== --> [2022-01-17T15:04:48.816Z] <!-- --> [2022-01-17T15:04:48.816Z] <!-- Effective Settings for 'jenkins' on 'ip-10-0-0-105' --> [2022-01-17T15:04:48.816Z] <!-- --> [2022-01-17T15:04:48.816Z] <!-- ====================================================================== --> [2022-01-17T15:04:48.816Z] <settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"> [2022-01-17T15:04:48.816Z] <localRepository>/var/lib/jenkins/.m2/repository</localRepository> [2022-01-17T15:04:48.816Z] <pluginGroups> [2022-01-17T15:04:48.816Z] <pluginGroup>org.apache.maven.plugins</pluginGroup> [2022-01-17T15:04:48.816Z] <pluginGroup>org.codehaus.mojo</pluginGroup> [2022-01-17T15:04:48.816Z] </pluginGroups> [2022-01-17T15:04:48.816Z] </settings> [2022-01-17T15:04:48.816Z] [2022-01-17T15:04:48.816Z]
In this logged data, the following line jumped out:
[2022-01-17T15:04:44.050Z] [withMaven] Maven installation not specified in the 'withMaven()' step and not found on the build agent but 'mvnw' script found in the workspace.
However, my declarative pipeline has this already:
tools { maven 'Maven_3.6.0' jdk 'jdk11' }
Both of those tools are confirmed configured properly in Global Tools settings:
On a hunch, I tried doing this in withMaven:
stage('Debug') { steps { withMaven(maven: 'Maven_3.6.0') { sh 'mvn help:effective-settings' } } }
And suddenly:
[Pipeline] { [Pipeline] withMaven [2022-01-17T15:09:52.843Z] [withMaven] Options: [] [2022-01-17T15:09:52.843Z] [withMaven] Available options: [2022-01-17T15:09:52.843Z] [withMaven] using JDK installation provided by the build agent [2022-01-17T15:09:52.854Z] [withMaven] using Maven global settings.xml 'global-maven-settings' with Maven servers credentials provided by Jenkins (replaceAll: true): [mavenServerId: 'com.mycompany.repo.releases', jenkinsCredentials: '7ad2488b-6087-4727-a1ca-6b9ced57baa6', username: 'ci', type: 'UsernamePasswordCredentialsImpl'], [mavenServerId: 'com.mycompany.repo.snapshots', jenkinsCredentials: '7ad2488b-6087-4727-a1ca-6b9ced57baa6', username: 'ci', type: 'UsernamePasswordCredentialsImpl'] [2022-01-17T15:09:52.856Z] [withMaven] using Maven installation 'Maven_3.6.0' [Pipeline] { [Pipeline] sh [2022-01-17T15:09:53.145Z] + mvn help:effective-settings [2022-01-17T15:09:53.145Z] ----- withMaven Wrapper script ----- [2022-01-17T15:09:53.145Z] Picked up JAVA_TOOL_OPTIONS: -Dmaven.ext.class.path="/var/lib/jenkins/workspace/NL_log-client-java_PR-25@tmp/withMaven26bf946c/pipeline-maven-spy.jar" -Dorg.jenkinsci.plugins.pipeline.maven.reportsFolder="/var/lib/jenkins/workspace/NL_log-client-java_PR-25@tmp/withMaven26bf946c" [2022-01-17T15:09:53.397Z] Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T18:41:47Z) [2022-01-17T15:09:53.397Z] Maven home: /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.6.0 [2022-01-17T15:09:53.397Z] Java version: 11.0.2, vendor: Oracle Corporation, runtime: /var/lib/jenkins/tools/hudson.model.JDK/jdk11/jdk-11.0.2 [2022-01-17T15:09:53.397Z] Default locale: en_US, platform encoding: UTF-8 [2022-01-17T15:09:53.397Z] OS name: "linux", version: "4.14.252-131.483.amzn1.x86_64", arch: "amd64", family: "unix" [2022-01-17T15:09:54.751Z] [INFO] [jenkins-event-spy] Generate /var/lib/jenkins/workspace/NL_log-client-java_PR-25@tmp/withMaven26bf946c/maven-spy-20220117-150954-550586148237436508350.log.tmp ... [2022-01-17T15:09:55.001Z] [INFO] Scanning for projects... [2022-01-17T15:09:55.552Z] [INFO] [2022-01-17T15:09:55.552Z] [INFO] ------------------< com.mycompany.ncp:log-client-java >------------------- [2022-01-17T15:09:55.552Z] [INFO] Building Log Client for Java 1.2.1-SNAPSHOT [2022-01-17T15:09:55.552Z] [INFO] --------------------------------[ jar ]--------------------------------- [2022-01-17T15:09:55.552Z] [INFO] [2022-01-17T15:09:55.552Z] [INFO] --- maven-help-plugin:3.2.0:effective-settings (default-cli) @ log-client-java --- [2022-01-17T15:09:56.103Z] [INFO] [2022-01-17T15:09:56.103Z] Effective user-specific configuration settings: [2022-01-17T15:09:56.103Z] [2022-01-17T15:09:56.103Z] <?xml version="1.0" encoding="UTF-8"?> [2022-01-17T15:09:56.103Z] <!-- ====================================================================== --> [2022-01-17T15:09:56.103Z] <!-- --> [2022-01-17T15:09:56.103Z] <!-- Generated by Maven Help Plugin on 2022-01-17T15:09:55Z --> [2022-01-17T15:09:56.103Z] <!-- See: http://maven.apache.org/plugins/maven-help-plugin/ --> [2022-01-17T15:09:56.103Z] <!-- --> [2022-01-17T15:09:56.103Z] <!-- ====================================================================== --> [2022-01-17T15:09:56.103Z] <!-- ====================================================================== --> [2022-01-17T15:09:56.103Z] <!-- --> [2022-01-17T15:09:56.103Z] <!-- Effective Settings for 'jenkins' on 'ip-10-0-0-105' --> [2022-01-17T15:09:56.103Z] <!-- --> [2022-01-17T15:09:56.103Z] <!-- ====================================================================== --> [2022-01-17T15:09:56.103Z] <settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"> [2022-01-17T15:09:56.103Z] <localRepository>/var/lib/jenkins/.m2/repository</localRepository> [2022-01-17T15:09:56.103Z] <interactiveMode>false</interactiveMode> [2022-01-17T15:09:56.103Z] <servers> [2022-01-17T15:09:56.103Z] <server> [2022-01-17T15:09:56.103Z] <username>ci</username> [2022-01-17T15:09:56.103Z] <password>***</password> [2022-01-17T15:09:56.103Z] <id>com.mycompany.repo.snapshots</id> [2022-01-17T15:09:56.103Z] </server> [2022-01-17T15:09:56.103Z] <server> [2022-01-17T15:09:56.103Z] <username>ci</username> [2022-01-17T15:09:56.103Z] <password>***</password> [2022-01-17T15:09:56.103Z] <id>com.mycompany.repo.releases</id> [2022-01-17T15:09:56.103Z] </server> [2022-01-17T15:09:56.103Z] </servers> [2022-01-17T15:09:56.103Z] <profiles> [2022-01-17T15:09:56.104Z] <profile> [2022-01-17T15:09:56.104Z] <repositories> [2022-01-17T15:09:56.104Z] <repository> [2022-01-17T15:09:56.104Z] <releases> [2022-01-17T15:09:56.104Z] <enabled>false</enabled> [2022-01-17T15:09:56.104Z] </releases> [2022-01-17T15:09:56.104Z] <snapshots /> [2022-01-17T15:09:56.104Z] <id>com.mycompany.repo.snapshots</id> [2022-01-17T15:09:56.104Z] <name>mycompany Snapshots</name> [2022-01-17T15:09:56.104Z] <url>https://artifact.mycompanyinternal.com/repository/maven-snapshots</url> [2022-01-17T15:09:56.104Z] </repository> [2022-01-17T15:09:56.104Z] <repository> [2022-01-17T15:09:56.104Z] <releases /> [2022-01-17T15:09:56.104Z] <snapshots> [2022-01-17T15:09:56.104Z] <enabled>false</enabled> [2022-01-17T15:09:56.104Z] </snapshots> [2022-01-17T15:09:56.104Z] <id>com.mycompany.repo.releases</id> [2022-01-17T15:09:56.104Z] <name>mycompany Releases</name> [2022-01-17T15:09:56.104Z] <url>https://artifact.mycompanyinternal.com/repository/maven-releases</url> [2022-01-17T15:09:56.104Z] </repository> [2022-01-17T15:09:56.104Z] </repositories> [2022-01-17T15:09:56.104Z] </profile> [2022-01-17T15:09:56.104Z] </profiles> [2022-01-17T15:09:56.104Z] <activeProfiles> [2022-01-17T15:09:56.104Z] <activeProfile>default</activeProfile> [2022-01-17T15:09:56.104Z] </activeProfiles> [2022-01-17T15:09:56.104Z] <pluginGroups> [2022-01-17T15:09:56.104Z] <pluginGroup>org.apache.maven.plugins</pluginGroup> [2022-01-17T15:09:56.104Z] <pluginGroup>org.codehaus.mojo</pluginGroup> [2022-01-17T15:09:56.104Z] </pluginGroups> [2022-01-17T15:09:56.104Z] </settings>
So, for whatever reason, withMaven is not using the maven tool declared on the agent which, in turn, prevents it from using the configured settings.
Just in case this detail matters, our pipeline is being managed and triggered via the Bitbucket Branch Source Plugin. We also echo all environment variables to logs in a previous stage and see this well before using withMaven:
[2022-01-17T15:29:13.376Z] M2_HOME=/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.6.0 [2022-01-17T15:29:13.376Z] MAVEN_HOME=/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.6.0 [2022-01-17T15:29:13.376Z] PATH=/var/lib/jenkins/tools/hudson.model.JDK/jdk11/jdk-11.0.2/bin:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.6.0/bin:/var/lib/jenkins/tools/hudson.model.JDK/jdk11/jdk-11.0.2/bin:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.6.0/bin:/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin/
I should also mention that the problem definitely extends beyond just help:effective-settings. The real world use case is that our internal artifact repository is not accessible because distributionManagement does not have authentication credentials. I can work around this by directly using config-file-provider (just like red888), but this entirely negates my purpose for using pipeline-maven-plugin.