0

I am in the process of setting up hudson with already existing Ant scripts so I would be using a custom workspace. However, I would like to have a python script set some environment variables, call Ant with the top level build file and perform some other actions if the build was successful. Is there a way I can have ant return a true/false value based on the build status so that I can make appropriate decisions and perform related actions.

4

1 に答える 1

1

タスクを使用すると、Ant はゼロ以外の終了値を返し<fail>ます。タスクは<fail>タスクと組み合わせることもでき<condition>ます:

<fail message="Missing file &quot;${foo}&quot">
    <condition>
       <not>
           <available file="${foo}" type="file"/>
       </not>
    </condition>
</fail>

これを使用して、ビルドしようとしていたものが実際にビルドされたことを確認し、そうでない場合はエラーでビルドを終了できます。

すぐに失敗したくない場合は、<condition>タスクを使用してプロパティを設定し、そのプロパティが設定されている場合に失敗することができます。

<fail message="Property foo.failed was set">
    <condition>
        <isset property="foo.failed"/>
    <condition>
</fail>

または単に:

Python が失敗ステータスを取得しない場合は、失敗時に終了値を設定することもできます。

Ant は、タスクが失敗したためにビルドが停止した場合、ゼロ以外の終了ステータスを返します。多くの Ant タスクにはhaltonfailureまたはfailonerrorがあり、デフォルトではエラーで停止または失敗しません。

于 2013-02-21T04:00:14.717 に答える