将参数传递给Maven发布版本 [英] Passing arguments to Maven release build

查看:171
本文介绍了将参数传递给Maven发布版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to release a library using Maven and perform a site-deploy to sourceforge (I have create an interactive shell first). The release is done by a Jenkins job (using the Maven Release Plugin for Jenkins).

我试过:

-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

但两次都是工作在网站挂起:部署第一个模块:

but both times the job hangs at site:deploy of the first module:

 [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

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

When I stop the job, the following gets printed at end:

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

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

which probably means that ${username} wasn't resolved.

如何解析$ {username}?

How can I resolve the ${username}?

编辑

请注意,以下运行正常:

Note that the following runs fine:

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

编辑2:
作为release:执行maven执行以下命令:

Edit 2: As part of release:perform maven executes the following command:

/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命令......

-Dusername=puce doesn't seem to get passed to this maven command...

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

Also note that help:effective-pom shows the following maven-release-plugin configuration:

<plugin>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.2.2</version>
  <configuration>
    <mavenExecutorId>forked-path</mavenExecutorId>
    <useReleaseProfile>false</useReleaseProfile>
    <arguments>-Psonatype-oss-release</arguments>
  </configuration>
</plugin>

因此'参数'被定义,其值似乎达到嵌入式maven命令而不是传递的值在命令行...

So 'arguments' gets defined and its value seems to reach the embedded maven command instead of the value passed on the command line...

推荐答案

覆盖

<plugin>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.2.2</version>
  <configuration>
    <mavenExecutorId>forked-path</mavenExecutorId>
    <useReleaseProfile>false</useReleaseProfile>
    <arguments>-Psonatype-oss-release</arguments>
  </configuration>
</plugin>

with

    <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
            <mavenExecutorId>forked-path</mavenExecutorId>
            <useReleaseProfile>false</useReleaseProfile>
            <arguments>-Psonatype-oss-release -Dusername=${username}</arguments>
        </configuration>
    </plugin>

其中一位父母做过这个伎俩。

in one of the parents did the trick.

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

It seems to be a bug that the value on the command line doesn't override the value in the POM.

这篇关于将参数传递给Maven发布版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆