将参数传递给Maven发布版本

我正在尝试使用Maven发布一个库并执行一个站点部署到sourceforge(我先创建了一个交互式shell)。 该版本由Jenkins工作完成(使用Jenkins的Maven Release Plugin)。

我试过了:

-X -e -Dresume=false -Dusername=puce release:prepare release:perform -Darguments="-Dusername=puce" 

 -X -e -Dresume=false -Dusername=puce -Darguments=-Dusername=puce release:prepare release:perform 

但两次工作都挂在现场:部署第一个模块:

  [INFO] --- maven-site-plugin:3.2:deploy (default-deploy) @ myproject-parent --- [INFO] Parent project loaded from repository: myGroupId:myOtherproject-parent:pom:1.0 [INFO] Parent project loaded from repository: myGroupId:myOtherproject-parent:pom:1.0 Using private key: /opt/jenkins/.ssh/id_dsa 

当我停止工作时,最后会打印以下内容:

 Password for ${username}@shell.sourceforge.net: channel stopped 

这可能意味着$ {username}未解决。

如何解析$ {username}?

编辑:

请注意以下运行正常:

 site-deploy -Psonatype-oss-release -Dusername=puce 

编辑2:作为发布的一部分:执行maven执行以下命令:

 /usr/share/maven/bin/mvn -s /tmp/release-settings7797889802430474959.xml deploy site-deploy --no-plugin-updates --batch-mode -Psonatype-oss-release -P nexus -f pom.xml 

-Dusername=puce似乎没有传递给这个maven命令……

另请注意help:effective-pom显示以下maven-release-plugin配置:

  maven-release-plugin 2.2.2  forked-path false -Psonatype-oss-release   

所以’arguments’被定义了,它的值似乎达到了嵌入式maven命令而不是命令行传递的值……

我过去成功完成的工作如下:

  • 在POM文件中定义属性,例如:

        
  • 将POM属性添加到POM文件中的插件配置,例如;

      org.apache.maven.plugins maven-release-plugin  ${release.arguments} ... 
  • 在命令行中通过属性传递参数,例如:

     mvn release:prepare -Drelease.arguments="-N -Prelease" 

希望这可以帮助。

重写

  maven-release-plugin 2.2.2  forked-path false -Psonatype-oss-release   

   maven-release-plugin  forked-path false -Psonatype-oss-release -Dusername=${username}   

在其中一个父母做了伎俩。

似乎是一个错误,命令行上的值不会覆盖POM中的值。

我的解决方案类似于Sander Verhagen's解决方案。 我只添加了一行。

我如何运行:

 mvn --batch-mode release:prepare -Denvironment=production 

我的配置:

    org.apache.maven.plugins maven-release-plugin 2.5.3  ${artifactId}-${version}-${environment} -Denvironment=${environment} release     

不同的是,现在我的子模块使用变量environment ,我不需要定义它两次(即-Darguments=-Denvironment=production -Denvironment=production )。 我还给了我不添加属性标签的灵活性。