Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-72414

When using withMaven, "mvn deploy" no longer uploads artifacts to Nexus.

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • pipeline-maven-plugin
    • None

      When using withMaven within my pipeline's constructs, the deploy plugin no longer tries to upload artifacts to Nexus. If I remove (comment out) the withMaven block, everything goes back to normal and deployment works.

      However, I obviously lose all the publishers I'm interested in (JUnit, JaCoCo, etc.). I'm using withMaven() { ... }  (i.e. default mode, no special options or constructs).

      In particular, I very strongly desire to not store actual build artifacts in Jenkins since they're already meant to be housed in Nexus (i.e. why double-store?).

      I need Maven to be the "agent" performing the upload to Nexus since the target repository may change "dynamically" depending on certain criteria (i.e. a Maven profile that gets activated based on envvars and such) and special circumstances (we're working to remove this, but for now it's a requirement).

      The deploy plugin in use is 3.1.1, but also fails with 2.7.

          [JENKINS-72414] When using withMaven, "mvn deploy" no longer uploads artifacts to Nexus.

          Mark Waite added a comment -

          drivera thanks for using Jenkins. When I read your bug report, I'm not sure of the steps that need to be taken to duplicate the issue. If you want others to consider investigating the issue, please provide enough details so that others can duplicate the problem. "How to report an issue" describes the types of information that are needed, including things like:

          • operating system
          • Java versions
          • plugins and their versions
          • installation method / runtime environment (container or standalone)
          • detailed steps that others can take to duplicate the problem, including a sample Pipeline job that shows the issue

          Mark Waite added a comment - drivera thanks for using Jenkins. When I read your bug report, I'm not sure of the steps that need to be taken to duplicate the issue. If you want others to consider investigating the issue, please provide enough details so that others can duplicate the problem. "How to report an issue" describes the types of information that are needed, including things like: operating system Java versions plugins and their versions installation method / runtime environment (container or standalone) detailed steps that others can take to duplicate the problem, including a sample Pipeline job that shows the issue

          Diego added a comment - - edited

          Yes, sorry. Here are more details (some updates to the Environment field, above):

          • Installation method: Jenkins is containerized in Docker
          • Agents are running in a separate Docker instance
          • Pipeline for testing:
            pipeline
            {
            
            	agent any
            
            	tools
            	{
            		jdk "11"
            		maven "latest"
            	}
            
            	stages
            	{
            		stage("Compile")
            		{
            			steps
            			{
            				withFolderProperties
            				{
            					// mvn() is a function that adds other flags if required, the final command executed is:
            					// mvn -Dstyle.color=always -T 6 -B deploy -Drevision=... -Dsha1=... -DdeployAtEnd=true -DretryFailedDeploymentCount=5 -DskipITs
            					// (it also takes into account if MVN_SCRIPT is set, and uses it if available, for when withMaven{} is used
            					mvn("-Dstyle.color=always -T 6 -B deploy");
            				}
            			}
            		}
            	}
            }
            
          • POM file:
            <?xml version="1.0" encoding="UTF-8"?>
            <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
                <modelVersion>4.0.0</modelVersion>
                <groupId>com.group.id</groupId>
                <artifactId>neo4j-demo</artifactId>
                <version>${revision}</version>
                <packaging>jar</packaging>
                <name>Neo4j Demo Analytics</name>
                <description>Neo4j Demo Analytics</description>
                <inceptionYear>2020</inceptionYear>
            
                <properties>
                    <revision>1.2.3</revision>
                    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                </properties>
            
                <scm>
                    <connection>scm:git:${git.repository}</connection>
                    <developerConnection>scm:git:${git.repository}</developerConnection>
                    <url>${git.repository}</url>
                    <tag>HEAD</tag>
                </scm>
            
                <distributionManagement>
                    <snapshotRepository>
                        <id>repo.snapshot</id>
                        <url>https://nexus.server.com/nexus/content/repositories/repo.snapshot/</url>
                    </snapshotRepository>
                    <repository>
                        <id>repo.release</id>
                        <url>https://nexus.server.com/nexus/content/repositories/repo.release/</url>
                    </repository>
                </distributionManagement>
            
                <build>
                    <plugins>
                        <plugin>
                            <groupId>com.amashchenko.maven.plugin</groupId>
                            <artifactId>gitflow-maven-plugin</artifactId>
                            <version>1.20.0</version>
                            <configuration>
                                <!-- optional configuration -->
                                <skipUpdateVersion>true</skipUpdateVersion>
                                <versionProperty>revision</versionProperty>
                            </configuration>
                        </plugin>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-jar-plugin</artifactId>
                            <version>3.3.0</version>
                            <configuration>
                                <archive>
                                    <manifestEntries>
                                        <SCM-Branch>${scmBranch}</SCM-Branch>
                                        <SCM-Revision>${commitHash}</SCM-Revision>
                                        <SCM-Build-Time>${buildTimestamp}</SCM-Build-Time>
                                    </manifestEntries>
                                </archive>
                                <excludes>
                                    <exclude>**/.*.sw*</exclude>
                                    <exclude>**/.sw*</exclude>
                                    <exclude>**/*~</exclude>
                                </excludes>
                            </configuration>
                        </plugin>
                        <plugin>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>buildnumber-maven-plugin</artifactId>
                            <version>3.2.0</version>
                            <executions>
                                <execution>
                                    <id>create-commitHash</id>
                                    <phase>generate-sources</phase>
                                    <goals>
                                        <goal>create</goal>
                                    </goals>
                                    <configuration>
                                        <doCheck>false</doCheck>
                                        <doUpdate>false</doUpdate>
                                        <shortRevisionLength>40</shortRevisionLength>
                                        <getRevisionOnlyOnce>true</getRevisionOnlyOnce>
                                        <revisionOnScmFailure>unknown</revisionOnScmFailure>
                                        <buildNumberPropertyName>commitHash</buildNumberPropertyName>
                                    </configuration>
                                </execution>
                                <execution>
                                    <id>create-buildTimestamp</id>
                                    <phase>generate-sources</phase>
                                    <goals>
                                        <goal>create-timestamp</goal>
                                    </goals>
                                    <configuration>
                                            <timestampPropertyName>buildTimestamp</timestampPropertyName>
                                            <timestampFormat>yyyy-MM-dd'T'HH:mm:ssZZ</timestampFormat>
                                            <timezone>UTC</timezone>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-deploy-plugin</artifactId>
                            <version>3.1.1</version>
                        </plugin>
                        <plugin>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>flatten-maven-plugin</artifactId>
                            <version>1.5.0</version>
                            <configuration>
                                <updatePomFile>true</updatePomFile>
                                <flattenMode>resolveCiFriendliesOnly</flattenMode>
                            </configuration>
                            <executions>
                                <execution>
                                    <id>flatten.process-resources</id>
                                    <phase>process-resources</phase>
                                    <goals>
                                        <goal>flatten</goal>
                                    </goals>
                                </execution>
                                <execution>
                                    <id>flatten.clean</id>
                                    <phase>clean</phase>
                                    <goals>
                                        <goal>clean</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </build>
            </project>
            

          The withMaven block is within the mvn() function. When the block is active, and I add "-X" to the maven command, I get a curious behavior in the logs:

          [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ neo4j-demo ---
          [DEBUG] Using mirror maven-default-http-blocker (http://0.0.0.0/) for apache.snapshots (http://people.apache.org/maven-snapshot-repository).
          [DEBUG] Dependency collection stats {ConflictMarker.analyzeTime=66731, ConflictMarker.markTime=36574, ConflictMarker.nodeCount=32, ConflictIdSorter.graphTime=39818, ConflictIdSorter.topsortTime=20662, ConflictIdSorter.conflictIdCount=14, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=467839, ConflictResolver.conflictItemCount=32, DefaultDependencyCollector.collectTime=6369188, DefaultDependencyCollector.transformTime=662310}
          [DEBUG] org.apache.maven.plugins:maven-deploy-plugin:jar:2.7
          [DEBUG]    org.apache.maven:maven-plugin-api:jar:2.0.6:compile
          [DEBUG]    org.apache.maven:maven-project:jar:2.0.6:compile
          [DEBUG]       org.apache.maven:maven-settings:jar:2.0.6:compile
          [DEBUG]       org.apache.maven:maven-profile:jar:2.0.6:compile
          [DEBUG]       org.apache.maven:maven-artifact-manager:jar:2.0.6:compile
          [DEBUG]          org.apache.maven:maven-repository-metadata:jar:2.0.6:compile
          [DEBUG]       org.apache.maven:maven-plugin-registry:jar:2.0.6:compile
          [DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
          [DEBUG]          junit:junit:jar:3.8.1:compile
          [DEBUG]          classworlds:classworlds:jar:1.1-alpha-2:compile
          [DEBUG]    org.apache.maven:maven-model:jar:2.0.6:compile
          [DEBUG]    org.apache.maven:maven-artifact:jar:2.0.6:compile
          [DEBUG]    org.codehaus.plexus:plexus-utils:jar:1.5.6:compile
          [DEBUG] Created new class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7
          [DEBUG] Importing foreign packages into class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7
          [DEBUG]   Imported:  < maven.api
          [DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7
          [DEBUG]   Included: org.apache.maven.plugins:maven-deploy-plugin:jar:2.7
          [DEBUG]   Included: junit:junit:jar:3.8.1
          [DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:1.5.6
          [DEBUG] Configuring mojo org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@5cb0d902]
          [DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy' with basic configurator -->
          [DEBUG]   (f) artifact = com.group.id:neo4j-demo:pom:2023.01.02-SNAPSHOT
          [DEBUG]   (f) attachedArtifacts = [com.group.id:neo4j-demo:zip:2023.01.02-SNAPSHOT]
          [DEBUG]   (s) localRepository =       id: local
                url: file:///cache/mvn/
             layout: default
          snapshots: [enabled => true, update => always]
           releases: [enabled => true, update => always]
             blocked: false
          
          [DEBUG]   (f) offline = false
          [DEBUG]   (f) packaging = pom
          [DEBUG]   (f) pomFile = /home/jenkins/workspace/itlab_arkcase_neo4j-demo_develop/.flattened-pom.xml
          [DEBUG]   (f) project = MavenProject: com.group.id:neo4j-demo:2023.01.02-SNAPSHOT @ /home/jenkins/workspace/itlab_arkcase_neo4j-demo_develop/.flattened-pom.xml
          [DEBUG]   (f) retryFailedDeploymentCount = 5
          [DEBUG]   (f) skip = false
          [DEBUG]   (f) updateReleaseInfo = false
          [DEBUG] -- end configuration --
          [DEBUG] Using transporter WagonTransporter with priority -1.0 for https://nexus.server.com/nexus/content/repositories/repo.snapshot/
          [DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://nexus.server.com/nexus/content/repositories/repo.snapshot/ with username=svc.10.1.jenkins, password=***
          [DEBUG] Writing tracking file /cache/mvn/com.group.id/neo4j-demo/2023.01.02-SNAPSHOT/resolver-status.properties
          [DEBUG] Writing tracking file /cache/mvn/com.group.id/neo4j-demo/resolver-status.properties
          13:08:35  [DEBUG] Using transporter WagonTransporter with priority -1.0 for https://nexus.server.com/nexus/content/repositories/repo.snapshot/
          13:08:35  [DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://nexus.server.com/nexus/content/repositories/repo.snapshot/ with username=svc.10.1.jenkins, password=***
          13:08:35  [DEBUG] Writing tracking file /cache/mvn/com.group.id/neo4j-demo/2023.01.02-SNAPSHOT/resolver-status.properties
          13:08:35  [INFO] ------------------------------------------------------------------------
          13:08:35  [INFO] BUILD SUCCESS
          13:08:35  [INFO] ------------------------------------------------------------------------
          

          Note that after "Writing tracking file" it automatically ends the deployment attempt. If I remove the withMaven {} block, it executes the deployment afterwards. In particular, I found this blog post which describes a possible situation in play re: Maven classloaders. I did try removing the deployAfter and retryFailedDeploymentCount parameters as well, but that also had no effect.

          As mentioned above, I used both the 2.7 and 3.1.1 versions of the deploy plugin and both had the same behavior.

          Diego added a comment - - edited Yes, sorry. Here are more details (some updates to the Environment field, above): Installation method: Jenkins is containerized in Docker Agents are running in a separate Docker instance Pipeline for testing: pipeline { agent any tools { jdk "11" maven "latest" } stages { stage( "Compile" ) { steps { withFolderProperties { // mvn() is a function that adds other flags if required, the final command executed is: // mvn -Dstyle.color=always -T 6 -B deploy -Drevision=... -Dsha1=... -DdeployAtEnd= true -DretryFailedDeploymentCount=5 -DskipITs // (it also takes into account if MVN_SCRIPT is set, and uses it if available, for when withMaven{} is used mvn( "-Dstyle.color=always -T 6 -B deploy" ); } } } } } POM file: <?xml version= "1.0" encoding= "UTF-8" ?> <project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > <modelVersion> 4.0.0 </modelVersion> <groupId> com.group.id </groupId> <artifactId> neo4j-demo </artifactId> <version> ${revision} </version> <packaging> jar </packaging> <name> Neo4j Demo Analytics </name> <description> Neo4j Demo Analytics </description> <inceptionYear> 2020 </inceptionYear> <properties> <revision> 1.2.3 </revision> <project.build.sourceEncoding> UTF-8 </project.build.sourceEncoding> </properties> <scm> <connection> scm:git:${git.repository} </connection> <developerConnection> scm:git:${git.repository} </developerConnection> <url> ${git.repository} </url> <tag> HEAD </tag> </scm> <distributionManagement> <snapshotRepository> <id> repo.snapshot </id> <url> https://nexus.server.com/nexus/content/repositories/repo.snapshot/ </url> </snapshotRepository> <repository> <id> repo.release </id> <url> https://nexus.server.com/nexus/content/repositories/repo.release/ </url> </repository> </distributionManagement> <build> <plugins> <plugin> <groupId> com.amashchenko.maven.plugin </groupId> <artifactId> gitflow-maven-plugin </artifactId> <version> 1.20.0 </version> <configuration> <!-- optional configuration --> <skipUpdateVersion> true </skipUpdateVersion> <versionProperty> revision </versionProperty> </configuration> </plugin> <plugin> <groupId> org.apache.maven.plugins </groupId> <artifactId> maven-jar-plugin </artifactId> <version> 3.3.0 </version> <configuration> <archive> <manifestEntries> <SCM-Branch> ${scmBranch} </SCM-Branch> <SCM-Revision> ${commitHash} </SCM-Revision> <SCM-Build-Time> ${buildTimestamp} </SCM-Build-Time> </manifestEntries> </archive> <excludes> <exclude> **/.*.sw* </exclude> <exclude> **/.sw* </exclude> <exclude> **/*~ </exclude> </excludes> </configuration> </plugin> <plugin> <groupId> org.codehaus.mojo </groupId> <artifactId> buildnumber-maven-plugin </artifactId> <version> 3.2.0 </version> <executions> <execution> <id> create-commitHash </id> <phase> generate-sources </phase> <goals> <goal> create </goal> </goals> <configuration> <doCheck> false </doCheck> <doUpdate> false </doUpdate> <shortRevisionLength> 40 </shortRevisionLength> <getRevisionOnlyOnce> true </getRevisionOnlyOnce> <revisionOnScmFailure> unknown </revisionOnScmFailure> <buildNumberPropertyName> commitHash </buildNumberPropertyName> </configuration> </execution> <execution> <id> create-buildTimestamp </id> <phase> generate-sources </phase> <goals> <goal> create-timestamp </goal> </goals> <configuration> <timestampPropertyName> buildTimestamp </timestampPropertyName> <timestampFormat> yyyy-MM-dd 'T' HH:mm:ssZZ </timestampFormat> <timezone> UTC </timezone> </configuration> </execution> </executions> </plugin> <plugin> <groupId> org.apache.maven.plugins </groupId> <artifactId> maven-deploy-plugin </artifactId> <version> 3.1.1 </version> </plugin> <plugin> <groupId> org.codehaus.mojo </groupId> <artifactId> flatten-maven-plugin </artifactId> <version> 1.5.0 </version> <configuration> <updatePomFile> true </updatePomFile> <flattenMode> resolveCiFriendliesOnly </flattenMode> </configuration> <executions> <execution> <id> flatten.process-resources </id> <phase> process-resources </phase> <goals> <goal> flatten </goal> </goals> </execution> <execution> <id> flatten.clean </id> <phase> clean </phase> <goals> <goal> clean </goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> The withMaven block is within the mvn() function. When the block is active, and I add "-X" to the maven command, I get a curious behavior in the logs: [INFO] --- maven-deploy-plugin:2.7:deploy ( default -deploy) @ neo4j-demo --- [DEBUG] Using mirror maven- default -http-blocker (http: //0.0.0.0/) for apache.snapshots (http://people.apache.org/maven-snapshot-repository). [DEBUG] Dependency collection stats {ConflictMarker.analyzeTime=66731, ConflictMarker.markTime=36574, ConflictMarker.nodeCount=32, ConflictIdSorter.graphTime=39818, ConflictIdSorter.topsortTime=20662, ConflictIdSorter.conflictIdCount=14, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=467839, ConflictResolver.conflictItemCount=32, DefaultDependencyCollector.collectTime=6369188, DefaultDependencyCollector.transformTime=662310} [DEBUG] org.apache.maven.plugins:maven-deploy-plugin:jar:2.7 [DEBUG] org.apache.maven:maven-plugin-api:jar:2.0.6:compile [DEBUG] org.apache.maven:maven-project:jar:2.0.6:compile [DEBUG] org.apache.maven:maven-settings:jar:2.0.6:compile [DEBUG] org.apache.maven:maven-profile:jar:2.0.6:compile [DEBUG] org.apache.maven:maven-artifact-manager:jar:2.0.6:compile [DEBUG] org.apache.maven:maven-repository-metadata:jar:2.0.6:compile [DEBUG] org.apache.maven:maven-plugin-registry:jar:2.0.6:compile [DEBUG] org.codehaus.plexus:plexus-container- default :jar:1.0-alpha-9-stable-1:compile [DEBUG] junit:junit:jar:3.8.1:compile [DEBUG] classworlds:classworlds:jar:1.1-alpha-2:compile [DEBUG] org.apache.maven:maven-model:jar:2.0.6:compile [DEBUG] org.apache.maven:maven-artifact:jar:2.0.6:compile [DEBUG] org.codehaus.plexus:plexus-utils:jar:1.5.6:compile [DEBUG] Created new class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7 [DEBUG] Importing foreign packages into class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7 [DEBUG] Imported: < maven.api [DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7 [DEBUG] Included: org.apache.maven.plugins:maven-deploy-plugin:jar:2.7 [DEBUG] Included: junit:junit:jar:3.8.1 [DEBUG] Included: org.codehaus.plexus:plexus-utils:jar:1.5.6 [DEBUG] Configuring mojo org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@5cb0d902] [DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy' with basic configurator --> [DEBUG] (f) artifact = com.group.id:neo4j-demo:pom:2023.01.02-SNAPSHOT [DEBUG] (f) attachedArtifacts = [com.group.id:neo4j-demo:zip:2023.01.02-SNAPSHOT] [DEBUG] (s) localRepository = id: local url: file: ///cache/mvn/ layout: default snapshots: [enabled => true , update => always] releases: [enabled => true , update => always] blocked: false [DEBUG] (f) offline = false [DEBUG] (f) packaging = pom [DEBUG] (f) pomFile = /home/jenkins/workspace/itlab_arkcase_neo4j-demo_develop/.flattened-pom.xml [DEBUG] (f) project = MavenProject: com.group.id:neo4j-demo:2023.01.02-SNAPSHOT @ /home/jenkins/workspace/itlab_arkcase_neo4j-demo_develop/.flattened-pom.xml [DEBUG] (f) retryFailedDeploymentCount = 5 [DEBUG] (f) skip = false [DEBUG] (f) updateReleaseInfo = false [DEBUG] -- end configuration -- [DEBUG] Using transporter WagonTransporter with priority -1.0 for https: //nexus.server.com/nexus/content/repositories/repo.snapshot/ [DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https: //nexus.server.com/nexus/content/repositories/repo.snapshot/ with username=svc.10.1.jenkins, password=*** [DEBUG] Writing tracking file /cache/mvn/com.group.id/neo4j-demo/2023.01.02-SNAPSHOT/resolver-status.properties [DEBUG] Writing tracking file /cache/mvn/com.group.id/neo4j-demo/resolver-status.properties 13:08:35 [DEBUG] Using transporter WagonTransporter with priority -1.0 for https: //nexus.server.com/nexus/content/repositories/repo.snapshot/ 13:08:35 [DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https: //nexus.server.com/nexus/content/repositories/repo.snapshot/ with username=svc.10.1.jenkins, password=*** 13:08:35 [DEBUG] Writing tracking file /cache/mvn/com.group.id/neo4j-demo/2023.01.02-SNAPSHOT/resolver-status.properties 13:08:35 [INFO] ------------------------------------------------------------------------ 13:08:35 [INFO] BUILD SUCCESS 13:08:35 [INFO] ------------------------------------------------------------------------ Note that after "Writing tracking file" it automatically ends the deployment attempt. If I remove the withMaven {} block, it executes the deployment afterwards. In particular, I found this blog post which describes a possible situation in play re: Maven classloaders. I did try removing the deployAfter and retryFailedDeploymentCount parameters as well, but that also had no effect. As mentioned above, I used both the 2.7 and 3.1.1 versions of the deploy plugin and both had the same behavior.

            Unassigned Unassigned
            drivera Diego
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: