[HAP-583] Git polling shows exception when job is currently running Created: 17/Mar/15  Updated: 11/Oct/15  Resolved: 19/Aug/15

Status: Resolved
Project: Jenkins Artifactory Plug-in
Component/s: Maven3
Affects Version/s: 2.2.7, 2.3.0, 2.3.1
Fix Version/s: 2.4.0

Type: Bug Priority: Critical
Reporter: Michael Niestegge Assignee: Eyal Ben Moshe (Inactive)
Resolution: Fixed Votes: 1
Labels: jenkins, plugin
Environment:

Jenkins 1.596.1 LTS
artifactory plugin 2.2.7 (also tested 2.2.4)
git-client-plugin 1.16.1 (also tested 1.15)
git-plugin 1.6 (also tested 1.5)

running on
Ubuntu 14.04 LTS
with local git installation 1.9.1



 Description   

I use git polling to trigger my jobs. When the job has the post-build action "Deploy artifacts to Artifactory" configured there is an exception within the "Git Polling Log":

Started on 17.03.2015 15:40:08
Using strategy: Default
[poll] Last Built Revision: Revision ae505d729d3b76e43782b351d7628024e065db61 (refs/remotes/origin/master)
ERROR: Failed to record SCM polling for hudson.maven.MavenModuleSet@42caa9c4[(BUILD) mp-modules master unit]
java.lang.RuntimeException: Unable to determine Maven version
	at org.jfrog.hudson.maven3.extractor.MavenExtractorEnvironment.isMavenVersionValid(MavenExtractorEnvironment.java:151)
	at org.jfrog.hudson.maven3.extractor.MavenExtractorEnvironment.buildEnvVars(MavenExtractorEnvironment.java:106)
	at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:914)
	at hudson.maven.AbstractMavenBuild.getEnvironment(AbstractMavenBuild.java:56)
	at hudson.maven.MavenModuleSetBuild.getEnvironment(MavenModuleSetBuild.java:167)
	at hudson.plugins.git.GitSCM.compareRemoteRevisionWithImpl(GitSCM.java:564)
	at hudson.plugins.git.GitSCM.compareRemoteRevisionWith(GitSCM.java:526)
	at hudson.scm.SCM.compareRemoteRevisionWith(SCM.java:380)
	at hudson.scm.SCM.poll(SCM.java:397)
	at hudson.model.AbstractProject._poll(AbstractProject.java:1446)
	at hudson.model.AbstractProject.poll(AbstractProject.java:1349)
	at jenkins.triggers.SCMTriggerItem$SCMTriggerItems$Bridge.poll(SCMTriggerItem.java:119)
	at hudson.triggers.SCMTrigger$Runner.runPolling(SCMTrigger.java:515)
	at hudson.triggers.SCMTrigger$Runner.run(SCMTrigger.java:544)
	at hudson.util.SequentialExecutionQueue$QueueEntry.run(SequentialExecutionQueue.java:118)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
	at org.jfrog.hudson.util.MavenVersionHelper.getMavenInstallation(MavenVersionHelper.java:105)
	at org.jfrog.hudson.util.MavenVersionHelper.isAtLeastVersion(MavenVersionHelper.java:81)
	at org.jfrog.hudson.util.MavenVersionHelper.isAtLeastResolutionCapableVersion(MavenVersionHelper.java:72)
	at org.jfrog.hudson.maven3.extractor.MavenExtractorEnvironment.isMavenVersionValid(MavenExtractorEnvironment.java:149)
	... 19 more

The exception occurs when the the git polling is triggered while the job is already in progress. The changes will not be polled again. If there is another change after the job has finished also the changes in the aborted poll will be build. As soon as I remove the "Deploy artifacts to Artifactory" action, it works.



 Comments   
Comment by Pavel [ 08/Jul/15 ]

I fixed it in this fork https://github.com/4public/jenkins-artifactory-plugin/tree/HAP-583

Comment by Pavel [ 09/Jul/15 ]

Few more words about this issue and my fix
Jenkins : 1.617 with multiple nodes, Linux env
Gerrit Trigger Jenkins plugin: 2.14.0
Artifactory Jenkins plugin: 2.3.0
Jenkins job is Maven project with Gerrit Trigger and Post Build Action to Deploy artifacts Artifactory
Exception generated in system log and does not touch build result, when Gerrit plugin generates successful notification to Gerrit on the very last step of the build.
At this time global Computer.currentComputer() is null in Artifactory getMavenInstallation call. More correct way is to use build.getBuiltOn().toComputer() call to get this object.
I have tested the return value of Computer.currentComputer() and build.getBuiltOn().toComputer() during build life cycle. All time these values were identical, except the very last step, when Gerrit plugin sends final notification. My build.getBuiltOn().toComputer() solution returns proper value , when original Computer.currentComputer() call returns null (visible in system Jenkins log only).

Fix is provided in forked jenkins-artifactory-plugin branch HAP-583 (branched from 2.3.0 release commit) : https://github.com/4public/jenkins-artifactory-plugin/tree/HAP-583
Only one file was modified: src/main/java/org/jfrog/hudson/util/MavenVersionHelper.java
Artifactory plugin was rebuilt from my branch and tests in my environment were successful

Comment by Eyal Ben Moshe (Inactive) [ 13/Jul/15 ]

Thanks for this fix Pavel!
It will be included in the next plugin release.

Comment by Eyal Ben Moshe (Inactive) [ 13/Jul/15 ]

@Michael - it would be great if you could confirm that this fix resolve your issue as well.
Here's a snapshot version that includes this fix:
http://repo.jfrog.org/artifactory/libs-snapshots-local/org/jenkins-ci/plugins/artifactory/2.3.2-SNAPSHOT/artifactory-2.3.2-20150713.144810-3.hpi
Thanks!

Generated at Sat Dec 07 02:53:12 UTC 2019 using JIRA 7.6.16#76018-sha1:9ed376192612a49536ac834c64177a0fed6290f5.