[HAP-953] NullPointerException in BuildInfoRecorder.addArtifactsToCurrentModule Created: 12/Jul/17  Updated: 27/Jul/17  Resolved: 27/Jul/17

Status: Resolved
Project: Jenkins Artifactory Plug-in
Component/s: None
Affects Version/s: 2.12.0, 2.12.1
Fix Version/s: 2.12.2

Type: Bug Priority: High
Reporter: Trevor Robinson Assignee: Eyal Ben Moshe
Resolution: Fixed Votes: 0
Labels: None
Environment:

Jenkins Artifactory Plugin version: 2.12.0
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00)
Java version: 1.8.0_131, vendor: Oracle Corporation
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-642.11.1.el6.x86_64", arch: "amd64", family: "unix"
CentOS 6.9


Issue Links:
Duplicate
duplicates HAP-952 NPE when performing "versions:set" goal Resolved
Regression:
Yes

 Description   

The following NPE occurs after executing mvn versions:set starting with version 2.12.0. The issue does not occur with 2.11.0.

[main] ERROR org.apache.maven.cli.MavenCli - NullPointerException
java.lang.NullPointerException
	at org.jfrog.build.extractor.maven.BuildInfoRecorder.addArtifactsToCurrentModule(BuildInfoRecorder.java:540)
	at org.jfrog.build.extractor.maven.BuildInfoRecorder.addFilesToCurrentModule(BuildInfoRecorder.java:485)
	at org.jfrog.build.extractor.maven.BuildInfoRecorder.finalizeAndAddModule(BuildInfoRecorder.java:472)
	at org.jfrog.build.extractor.maven.BuildInfoRecorder.finalizeModule(BuildInfoRecorder.java:398)
	at org.jfrog.build.extractor.maven.BuildInfoRecorder.projectSucceeded(BuildInfoRecorder.java:214)
	at org.apache.maven.lifecycle.internal.DefaultExecutionEventCatapult.fire(DefaultExecutionEventCatapult.java:74)
	at org.apache.maven.lifecycle.internal.DefaultExecutionEventCatapult.fire(DefaultExecutionEventCatapult.java:42)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:126)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

The pom.xml is extremely simple:

<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>mygroup</groupId>
    <artifactId>myproject</artifactId>
    <version>0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>21.0</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

In case it matters, this is part of a (multibranch) pipeline project:

    def server = Artifactory.server("...")
    def maven = Artifactory.newMavenBuild()
    maven.tool = "Maven 3.3.9"
    maven.resolver releaseRepo:'libs-release', snapshotRepo:'libs-snapshot', server: server
    maven.deployer releaseRepo:'libs-release-local', snapshotRepo:'libs-snapshot-local', server: server
    // ...
    stage('Set Version') {
        maven.opts = "-DnewVersion=${version} -DartifactId=* -DoldVersion=*"
        maven.run pom: 'pom.xml', goals: 'versions:set'
    }
    stage('Build') {
        maven.opts = '...'
        buildInfo = maven.run pom: 'pom.xml', goals: profiles + ' clean install site'
    }


 Comments   
Comment by Yahav Itzhak [ 13/Jul/17 ]

Trevor Robinson,
We fixed the issue. Here is the link to the commit:
https://github.com/JFrogDev/build-info/commit/baae39172587ea1c436e4189ff35747b81482586
Here is a download link for a snapshot version which includes the fix:
https://oss.jfrog.org/oss-snapshot-local/org/jenkins-ci/plugins/artifactory/2.12.2-SNAPSHOT/artifactory-2.12.2-20170713.063853-5.hpi

We would appreciate your feedback for it.

Comment by Trevor Robinson [ 13/Jul/17 ]

Thanks, that fixed it!

Generated at Sun Nov 17 20:24:09 UTC 2019 using JIRA 7.6.16#76018-sha1:9ed376192612a49536ac834c64177a0fed6290f5.