执行default-cli of goal org.apache.maven.plugins:maven-release-plugin:2.2.2:prepare failed。空指针异常

时间:2015-08-04 17:37:08

标签: maven jenkins release

这是上下文: 我已使用以下命令(在Jenkins中使用maven-release-plugin调用)成功构建了项目

mvn clean -Pall
mvn generate-sources -Pgs 
mvn -PjenkinsBuild install package assembly:single -Pall -Denvironment=dev

现在,当我尝试使用以下命令在Jenkins中使用maven-release-plugin发布项目时。它失败了。(错误日志和pom在最后)

mvn -X release:prepare release:perform

尝试了一些不成功的解决方案: 1.修改了maven-release-plugin的配置,怀疑开发人员和Jenkins正在使用不同的SVN版本。

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.4.1</version>
  <configuration>
    <branchBase>${svn.base}/branches/releases</branchBase>
    <tagBase>${svn.base}/tags/releases/</tagBase>
    <autoVersionSubmodules>true</autoVersionSubmodules>
    <suppressCommitBeforeBranch>true</suppressCommitBeforeBranch>
    <remoteTagging>false</remoteTagging>
    <updateBranchVersions>true</updateBranchVersions>
    <updateWorkingCopyVersions>false</updateWorkingCopyVersions>
    <providerImplementations>
          <svn>javasvn</svn>
    </providerImplementations>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
      <artifactId>maven-scm-provider-svnjava</artifactId>
      <version>2.0.6</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</plugin>
  1. 尝试根据其中一项建议明确添加groupID

    tc.strongview strongview皂客户端 罐 Strongview SOAP客户端

  2. POM的一部分

    http://maven.apache.org/xsd/maven-4.0.0.xsd">     4.0.0

    <groupId>tc.strongview</groupId>
    <artifactId>strongview-etl-core</artifactId>
    <version>0.2.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    
        <scm>
        <connection>
            scm:svn:https://xxxxxxxxx/svn/strongview-etl-core/branches/releases/strongview-etl-core-0.2
        </connection>
        <developerConnection>
            scm:svn:https://xxxxxxxxx/svn/strongview-etl-core/branches/releases/strongview-etl-core-0.2
        </developerConnection>
        <url>https://xxxxxxxxx/svn/strongview-etl-core/branches/releases/strongview-etl-core-0.2
        </url>
        </scm>
    
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    
    <modules>
        <module>strongview-etl-common</module>
        <module>strongview-soap-client</module>
        <module>strongview-etl-definitions</module>
    </modules>
    
    <distributionManagement>
    ...................................................
    ...................................................
    ...................................................
    </distributionManagement>
    
    <repositories>
    ...................................................
    ...................................................
    ...................................................
    </repositories>
    
    <profiles>
    ...................................................
    ...................................................
    ...................................................
    </profile>
    
    </profiles>
    
    <properties>
    ...................................................
    ...................................................
    ...................................................
    </properties>
    
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <extensions>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-ssh</artifactId>
                <version>2.9</version>
            </extension>
            <extension>
                <groupId>com.github.shyiko.servers-maven-extension</groupId>
                <artifactId>servers-maven-extension</artifactId>
                <version>1.3.0</version>
            </extension>
        </extensions>
    
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.2</version>
                <configuration>
                    <branchBase>${svn.base}/branches/releases</branchBase>
                    <tagBase>${svn.base}/tags/releases/</tagBase>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <suppressCommitBeforeBranch>true</suppressCommitBeforeBranch>
                    <remoteTagging>false</remoteTagging>
                    <updateBranchVersions>true</updateBranchVersions>
                    <updateWorkingCopyVersions>false</updateWorkingCopyVersions>
                </configuration>
            </plugin>
    
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptors>
                        <descriptor>${project.parent.basedir}/assembly/distribution.xml</descriptor>
                    </descriptors>
                    <appendAssemblyId>false</appendAssemblyId>
                    <finalName>${distribution.name}</finalName>
                    <includeProjectBuildFilters>true</includeProjectBuildFilters>
                    <ignoreMissingDescriptor>true</ignoreMissingDescriptor>
                </configuration>
            </plugin>
    
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>wagon-maven-plugin</artifactId>
                <version>1.0</version>
                <configuration>
                    <serverId>${deployment.server}</serverId>
                    <fromDir>${project.build.directory}</fromDir>
                    <includes>${distribution.name}.zip</includes>
                    <url>scp://${etl.server.url}:${etl.server.distribution.dir}</url>
                </configuration>
            </plugin>
    
        </plugins>
    </build>
    
    <dependencyManagement>
    ...................................................
    ...................................................
    ...................................................
    </dependencies>
    

    使用Maven 3.3.3和maven-release-plugin 2.5.2发布的新错误日志和简单的&#34;发布:准备发布:执行&#34;

    Started by user 
    [EnvInject] - Loading node environment variables.
    Building on master in workspace /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven
    Cleaning up /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven/.
    Deleting /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven/pom.xml.releaseBackup
    Deleting /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven/release.properties
    Deleting /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven/pom.xml
    Deleting /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven/strongview-etl-common/pom.xml.releaseBackup
    Deleting /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven/strongview-soap-client/pom.xml.releaseBackup
    Deleting /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven/strongview-etl-definitions/pom.xml.releaseBackup
    Updating https://xxxxxxxxx/svn/strongview-etl-core/branches/releases/strongview-etl-core-0.2 at revision '2015-08-04T15:33:30.474 -0400'
    At revision 80
    no change for https://xxxxxxxxx/svn/strongview-etl-core/branches/releases/strongview-etl-core-0.2 since the previous build
    Parsing POMs
    [strongview-etl-core-Release4 - Latest Maven] $ /opt/jdk1.8.0_45/bin/java -Xmx2048m -XX:MaxPermSize=512m -cp /data/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.4.jar:/data/jenkins/tools/hudson.tasks.Maven_MavenInstallation/3.3.3/boot/plexus-classworlds-2.5.2.jar:/data/jenkins/tools/hudson.tasks.Maven_MavenInstallation/3.3.3/conf/logging jenkins.maven3.agent.Maven31Main /data/jenkins/tools/hudson.tasks.Maven_MavenInstallation/3.3.3 /var/cache/jenkins/war/WEB-INF/lib/remoting-2.36.jar /data/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.4.jar /data/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.4.jar 35483
    Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
    <===[JENKINS REMOTING CAPACITY]===>channel started
    log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
    log4j:WARN Please initialize the log4j system properly.
    Executing Maven:  -B -f /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven/pom.xml -DdevelopmentVersion=0.2.1-SNAPSHOT -DreleaseVersion=0.2.0 -X -Dresume=false release:prepare release:perform
    Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T07:57:37-04:00)
    Maven home: /data/jenkins/tools/hudson.tasks.Maven_MavenInstallation/3.3.3
    Java version: 1.8.0_45, vendor: Oracle Corporation
    Java home: /opt/jdk1.8.0_45/jre
    Default locale: en_US, platform encoding: UTF-8
    OS name: "linux", version: "2.6.32-279.14.1.el6.x86_64", arch: "amd64", family: "unix"
    [INFO] Error stacktraces are turned on.
    [DEBUG] Reading global settings from /data/jenkins/tools/hudson.tasks.Maven_MavenInstallation/3.3.3/conf/settings.xml
    [DEBUG] Reading user settings from /home/jenkins/.m2/settings.xml
    [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Build Order:
    [INFO] 
    [INFO] strongview-etl-core
    [INFO] Strongview SOAP Client
    [INFO] strongview-etl-common
    [INFO] strongview-etl-definitions
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building strongview-etl-core 0.2.0-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-release-plugin:2.5.2:prepare (default-cli) @ strongview-etl-core ---
    [INFO] Verifying that there are no local modifications...
    [INFO]   ignoring changes on: **/pom.xml.releaseBackup, **/pom.xml.next, **/pom.xml.tag, **/pom.xml.branch, **/release.properties, **/pom.xml.backup
    [INFO] Executing: /bin/sh -c cd "/data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven" && svn --non-interactive status
    [INFO] Working directory: /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven
    [DEBUG] ?       release.properties
    [DEBUG] Ignoring changed file: release.properties
    [INFO] Checking dependencies and plugins for snapshots ...
    [INFO] Transforming 'strongview-etl-core'...
    [INFO]   Ignoring artifact version update for expression ${project.version}
    [INFO]   Ignoring artifact version update for expression ${project.version}
    [INFO] Transforming 'Strongview SOAP Client'...
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO] 
    [INFO] strongview-etl-core ................................ FAILURE [  2.944 s]
    [INFO] Strongview SOAP Client ............................. SKIPPED
    [INFO] strongview-etl-common .............................. SKIPPED
    [INFO] strongview-etl-definitions ......................... SKIPPED
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 5.724 s
    [INFO] Finished at: 2015-08-04T15:33:41-04:00
    [INFO] Final Memory: 20M/139M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.2:prepare (default-cli) on project strongview-etl-core: Execution default-cli of goal org.apache.maven.plugins:maven-release-plugin:2.5.2:prepare failed. NullPointerException -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.2:prepare (default-cli) on project strongview-etl-core: Execution default-cli of goal org.apache.maven.plugins:maven-release-plugin:2.5.2:prepare failed.
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        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.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
        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:497)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
        at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)
        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:497)
        at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
        at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
        at hudson.remoting.UserRequest.perform(UserRequest.java:118)
        at hudson.remoting.UserRequest.perform(UserRequest.java:48)
        at hudson.remoting.Request$2.run(Request.java:328)
        at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
        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: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.apache.maven.plugins:maven-release-plugin:2.5.2:prepare failed.
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 31 more
    Caused by: java.lang.NullPointerException
        at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.translateUrlPath(AbstractRewritePomsPhase.java:847)
        at org.apache.maven.shared.release.phase.RewritePomsForReleasePhase.translateScm(RewritePomsForReleasePhase.java:202)
        at org.apache.maven.shared.release.phase.RewritePomsForReleasePhase.transformScm(RewritePomsForReleasePhase.java:64)
        at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.transformDocument(AbstractRewritePomsPhase.java:330)
        at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.transformProject(AbstractRewritePomsPhase.java:231)
        at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.transform(AbstractRewritePomsPhase.java:131)
        at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.execute(AbstractRewritePomsPhase.java:116)
        at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:234)
        at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:169)
        at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:146)
        at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:107)
        at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:286)
        at org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:240)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        ... 32 more
    [ERROR] 
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
    [JENKINS] Archiving /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven/strongview-etl-definitions/pom.xml to tc.strongview/strongview-etl-definitions/0.2.0-SNAPSHOT/strongview-etl-definitions-0.2.0-SNAPSHOT.pom
    [JENKINS] Archiving /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven/strongview-soap-client/pom.xml to tc.strongview/strongview-soap-client/0.2.0-SNAPSHOT/strongview-soap-client-0.2.0-SNAPSHOT.pom
    [JENKINS] Archiving /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven/strongview-etl-common/pom.xml to tc.strongview/strongview-etl-common/0.2.0-SNAPSHOT/strongview-etl-common-0.2.0-SNAPSHOT.pom
    [JENKINS] Archiving /data/jenkins/workspace/strongview-etl-core-Release4 - Latest Maven/pom.xml to tc.strongview/strongview-etl-core/0.2.0-SNAPSHOT/strongview-etl-core-0.2.0-SNAPSHOT.pom
    channel stopped
    Finished: FAILURE
    

2 个答案:

答案 0 :(得分:0)

首先是我的想法。你为什么要使用2011年的maven-release-plugin 2.2.2的古老版本?不是更新的版本?

为什么你使用Maven 3.0.3的非常错误的版本?至少不是3.0.X发行版(3.0.5)的最后一个?

此外,您正在调用maven:

mvn clean -Pall
mvn generate-sources -Pgs 
mvn -PjenkinsBuild install package assembly:single -Pall -Denvironment=dev

这表明你并不了解Maven的生命周期。

如果您致电mvn package,则会运行所有life cycle phase,包括install,这意味着致电:

mvn install package

没有意义。 此外,您正在调用mvn ...assembly:single,这也没有意义。您应该将maven-assembly-plugin的执行绑定到生命周期。您在pom文件中配置的另一点:

$ {project.parent.basedir} /assembly/distribution.xml

您不应该使用这样的配置离开当前模块的位置,这会造成麻烦。

realy Maven构建应始终可以通过使用这样的简单构建来调用:

mvn clean deploy

如果你想发布它应该像这样工作:

mvn release:prepare release:perform

如果这不起作用,我并不感到惊讶,您在使用CI服务器时遇到了麻烦。

此外,您违反了SVN中的最佳做法...使用标签/主干/分支机构概念。

在日志中,我可以看到以下内容:

Building on master in workspace /data/jenkins/workspace/strongview-etl-core-Release
Checking out a fresh workspace because there's no workspace at /data/jenkins/workspace/strongview-etl-core-Release
Cleaning local Directory .
Checking out https://xxxxxxxx/svn/strongview-etl-core/branches/releases/strongview-etl-core-0.2 at revision '2015-08-04T10:08:20.758 -0400'
.....................................................................................................................
.....................................................................................................................
.....................................................................................................................
AU        pom.xml
 U        .
At revision 77
no change for https://svn.transcontinental.ca/svn/strongview-etl-core/branches/releases/strongview-etl-core-0.2 since the previous build
[strongview-etl-core-Release] $ /bin/sh -xe /data/jenkins/tmp/hudson5945883868250298288.sh
+ cd /data/jenkins/workspace/strongview-etl-core-Release/

这告诉我你已经在一个无法正常工作的标签上,因为要做一个发布你应该在你的pom文件中包含-SNAPSHOT版本的分支或主干上。 。它看起来不像..

答案 1 :(得分:0)

对我来说,已解决的scm标签和发布插件已移至child pom。这意味着从父pom中删除了scm标签和发布插件详细信息