12

Maven を使用してライブラリをリリースし、sourceforge へのサイト デプロイを実行しようとしています (最初にインタラクティブ シェルを作成しました)。リリースは 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

ただし、どちらの場合も、最初のモジュールの site:deploy でジョブがハングします。

 [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: release:perform の一部として、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 構成を示していることにも注意してください。

<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コマンドに到達するようです...

4

3 に答える 3

19

私が過去に成功したことは次のとおりです。

  • POM ファイルでプロパティを定義します。例:

    <properties>
        <release.arguments></release.arguments>
    </properties>
    
  • POM ファイルのプラグイン構成に POM プロパティを追加します。

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
            <arguments>${release.arguments}</arguments>
           ...
    
  • コマンドラインでプロパティを介して引数を渡します。例:

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

お役に立てれば。

于 2013-04-15T04:24:45.560 に答える
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>

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

親の1人でトリックを行いました。

コマンドラインの値がPOMの値を上書きしないのはバグのようです。

于 2013-04-15T22:23:56.197 に答える
0

私の解決策はに似ていましたSander Verhagen's。私はラインだけを追加しました。

私が実行する方法:

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

私の設定:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.5.3</version>
            <configuration>
                <tag>${artifactId}-${version}-${environment}</tag>
                <arguments>-Denvironment=${environment}</arguments>
              <releaseProfiles>release</releaseProfiles>
            </configuration>
        </plugin>
    </plugins>
</build>

違いは、サブモジュールが変数を使用するようになり、変数environmentを 2 回定義する必要がないことです(つまり-Darguments=-Denvironment=production -Denvironment=production)。また、プロパティ タグを追加しないという柔軟性も提供します。

于 2018-08-28T05:12:10.270 に答える