将参数传递给Maven发布版本

Puc*_*uce 12 java maven maven-release-plugin jenkins

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

我试过了:

-X -e -Dresume=false -Dusername=puce release:prepare release:perform -Darguments="-Dusername=puce"
Run Code Online (Sandbox Code Playgroud)

-X -e -Dresume=false -Dusername=puce -Darguments=-Dusername=puce release:prepare release:perform
Run Code Online (Sandbox Code Playgroud)

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

 [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
Run Code Online (Sandbox Code Playgroud)

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

Password for ${username}@shell.sourceforge.net: channel stopped
Run Code Online (Sandbox Code Playgroud)

这可能意味着$ {username}未得到解决.

如何解析$ {username}?

编辑:

请注意,以下运行正常:

site-deploy -Psonatype-oss-release -Dusername=puce
Run Code Online (Sandbox Code Playgroud)

编辑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
Run Code Online (Sandbox Code Playgroud)

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

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

<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>
Run Code Online (Sandbox Code Playgroud)

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

San*_*gen 18

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

希望这可以帮助.


Puc*_*uce 8

重写

<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>
Run Code Online (Sandbox Code Playgroud)

    <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
            <mavenExecutorId>forked-path</mavenExecutorId>
            <useReleaseProfile>false</useReleaseProfile>
            <arguments>-Psonatype-oss-release -Dusername=${username}</arguments>
        </configuration>
    </plugin>
Run Code Online (Sandbox Code Playgroud)

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

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