jfrog / jenkins-artifactory-plugin

Jenkins artifactory plugin
http://jenkins-ci.org/
116 stars 190 forks source link

Pipeline with rtMaven.run hangs when exec-maven-plugin is used #950

Open bdkdevops opened 1 month ago

bdkdevops commented 1 month ago

Bug Description

Pipeline log:

10:10:54  [main] WARNING org.jenkinsci.plugins.pipeline.maven.eventspy.handler.CatchAllExecutionHandler - [jenkins-event-spy] Unexpected Maven project file name 'testPom.xml', problems may occur
10:10:55  [main] WARNING org.jenkinsci.plugins.pipeline.maven.eventspy.handler.ProjectSucceededExecutionHandler - [jenkins-event-spy] Unexpected Maven project file name 'testPom.xml', problems may occur
10:10:55  [main] INFO org.jfrog.build.extractor.maven.BuildDeploymentHelper - Artifactory Build Info Recorder: Saving Build Info to '/home/jenkins/agent/workspace/Simple_Artifact_Plugin_Test/SBDK-6802/target/build-info.json'
10:10:55  [main] INFO org.jfrog.build.extractor.maven.BuildDeploymentHelper - Artifactory Build Info Recorder: deploy artifacts set to false, artifacts will not be deployed...
10:10:55  [main] INFO org.jfrog.build.extractor.maven.BuildDeploymentHelper - Artifactory Build Info Recorder: publish build info set to false, build info will not be published...
10:10:55  [main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
10:10:55  [main] INFO org.apache.maven.cli.event.ExecutionEventLogger - BUILD SUCCESS
10:10:55  [main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
10:10:55  [main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Total time:  23.266 s
10:10:55  [main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Finished at: 2024-10-14T10:10:55+02:00
10:10:55  [main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
10:10:55  [main] WARNING org.jenkinsci.plugins.pipeline.maven.eventspy.handler.MavenExecutionResultHandler - [jenkins-event-spy] Unexpected Maven project file name 'testPom.xml', problems may occur
10:10:55  [main] INFO org.jenkinsci.plugins.pipeline.maven.eventspy.reporter.FileMavenEventReporter - [jenkins-event-spy] Generated /home/jenkins/agent/workspace/Simple_Artifact_Plugin_Test@tmp/withMaven3a1ae27f/maven-spy-20241014-101031-8796038905462900611039.log
#### This is where the pipeline hangs ####

Jenkins logger:

Oct 14, 2024 10:10:25 AM FINEST org.jfrog.hudson.util.JenkinsBuildInfoLog
Base URL: api/system/version
Oct 14, 2024 10:10:25 AM FINEST org.jfrog.hudson.util.JenkinsBuildInfoLog
Version result: {"version":"7.90.10","revision":"79010900","servicesVersions":{"package_handler_version":""},"addons":["ha","build","docker","helmoci","oci","packages-archive","vagrant","replication","filestore","curation","plugins","worker","gems","composer","npm","bower","nuget","debian","opkg","rpm","cocoapods","conan","vcs","release-bundle","jf-connect","jf-event","replicator","keys","alpine","analytics","cargo","chef","federated","git","observability","onboarding","pub","rest","swift","lead-artifact-detector","conda","terraform","tracker","license","puppet","ldap","sso","layouts","properties","search","securityresourceaddon","filtered-resources","p2","watch","webstart","support","xray","retention","policies"],"license":"6e996ef8b1590afcf8dba165bdd4894f4dffdfd93","entitlements":{"EVENT_BASED_PULL_REPLICATION":true,"SMART_REMOTE_TARGET_FOR_EDGE":false,"REPO_REPLICATION":true,"MULTIPUSH_REPLICATION":true}}
Oct 14, 2024 10:10:25 AM FINEST org.jfrog.hudson.util.JenkinsBuildInfoLog
Base URL: api/system/usage
Oct 14, 2024 10:10:25 AM FINEST org.jfrog.hudson.util.JenkinsBuildInfoLog
Usage info sent successfully.
Oct 14, 2024 10:10:29 AM FINEST org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecProc
Waiting for websocket to close on command finish (java.util.concurrent.CountDownLatch@793a7876[Count = 1])
Oct 14, 2024 10:11:29 AM FINE org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecProc
sent a newline to keep socket alive

Additional context

Issue seems to be related to:

Expected behavior

Versions

To Reproduce

Jenkinsfile:

pipeline {

    // TODO: Fill in your values for xxx

    agent {
        label 'xxx'
    }
    options {
        disableConcurrentBuilds()
        timestamps ()
    }
    stages {
        stage ('Maven Build') {
            steps {
                container('xxx') {
                    script {
                        withMaven(jdk: 'xxx', maven: 'xxx', mavenSettingsConfig: 'xxx') {
                            def server = Artifactory.server('DRV-ZAR-Server')
                            def rtMaven = Artifactory.newMavenBuild()
                            def buildInfo = Artifactory.newBuildInfo()                            
                            buildInfo.name = 'bund-zfa-test'                            
                            rtMaven.deployer releaseRepo: 'xxx', snapshotRepo: 'xxx', server: server
                            rtMaven.resolver releaseRepo: 'xxx', snapshotRepo: 'xxx', server: server

                            rtMaven.run pom: 'testPom.xml', goals: 'clean compile -DskipExec=false -DskipAntRun=true', buildInfo: buildInfo
                        }
                    }
                }
            }
        }
    }
}

testPom.xml:

<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>my.test</groupId>
  <artifactId>artifactory-plugin-test</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>3.4.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.3.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
          <execution>
            <id>sh-test-antrun-1</id>
            <phase>process-sources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <skip>${skipAntRun}</skip>
              <target>
                 <exec executable="sh"
                  dir="${project.build.directory}" failonerror="true">
                  <arg line="-c &quot;echo 'Sleeping for 10 secs' &quot;" />
                </exec>
                <exec executable="sh"
                  dir="${project.build.directory}" failonerror="true">
                  <arg line="-c &quot;date &quot;" />
                </exec>
                <exec executable="sh"
                  dir="${project.build.directory}" failonerror="true">
                  <arg line="-c &quot;sleep 10 &quot;" />
                </exec>
                <exec executable="sh"
                  dir="${project.build.directory}" failonerror="true">
                  <arg line="-c &quot;echo RC: $? &quot;" />
                </exec>
                <exec executable="sh"
                  dir="${project.build.directory}" failonerror="true">
                  <arg line="-c &quot;date &quot;" />
                </exec>
                 <exec executable="sh"
                  dir="${project.build.directory}" failonerror="true">
                  <arg line="-c &quot;ps -ef &quot;" />
                </exec>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>sh-test-exec-1</id>
            <phase>process-sources</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <skip>${skipExec}</skip>
              <workingDirectory>${project.build.directory}</workingDirectory>
              <executable>sh</executable>
              <arguments>
                <argument>-c</argument>
                <argument>
                  echo Sleeping for 10 secs &amp;&amp; \
                  date &amp;&amp; \
                  sleep 10 &amp;&amp; \
                  echo "RC: $?" &amp;&amp; \
                  date &amp;&amp; \
                  echo "done" &amp;&amp; \
                  ps -ef
                </argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>