【发布时间】:2019-08-20 05:28:10
【问题描述】:
我有一个 Jenkins 构建,并且我提供了一个带有大写值的构建参数(构建参数应始终为大写),如果用户提供的是小写值,则构建应该会失败。
请提供有关如何使用 ANT 检查提供的 Jenkins 构建参数是大写还是小写的输入。谢谢!
【问题讨论】:
标签: jenkins parameters ant uppercase
我有一个 Jenkins 构建,并且我提供了一个带有大写值的构建参数(构建参数应始终为大写),如果用户提供的是小写值,则构建应该会失败。
请提供有关如何使用 ANT 检查提供的 Jenkins 构建参数是大写还是小写的输入。谢谢!
【问题讨论】:
标签: jenkins parameters ant uppercase
这可以使用 Ant 的matches 条件来完成。下面的示例中使用了嵌套的regexp 以避免重复。
<target name="check-uppercase">
<property name="test1" value="lowercase" />
<property name="test2" value="MixedCase" />
<property name="test3" value="UPPERCASE" />
<regexp id="all.uppercase" pattern="^[A-Z]+$" />
<condition property="test1.isUppercase" value="true" else="false">
<matches string="${test1}">
<regexp refid="all.uppercase" />
</matches>
</condition>
<condition property="test2.isUppercase" value="true" else="false">
<matches string="${test2}">
<regexp refid="all.uppercase" />
</matches>
</condition>
<condition property="test3.isUppercase" value="true" else="false">
<matches string="${test3}">
<regexp refid="all.uppercase" />
</matches>
</condition>
<echo message="test1 uppercase? ${test1.isUppercase}" />
<echo message="test2 uppercase? ${test2.isUppercase}" />
<echo message="test3 uppercase? ${test3.isUppercase}" />
</target>
【讨论】: