Jenkins多配置项目用户自定义axis环境变量
我正在尝试在 Jenkins 中设置一个具有单个用户定义轴(称为“轴”)的多配置项目。然后,与每个配置关联的值将用于调用 ${axis}/pom.xml
中的顶级 Maven 目标。问题是,我找不到正确的语法,如果它确实存在的话 (${axis}
, $axis
, $AXIS 和
${env.axis}
都失败)。我认为这将是 shell 语法,但它似乎不是,但无论如何它应该要么简单要么不可能。是否可以?
I am trying to set up a multi-configuration project in Jenkins with a single user-defined axis (call it "axis"). The value associated with each configuration would then be used to invoke top-level maven targets in ${axis}/pom.xml
. The trouble is, I can't find the proper syntax for this, if indeed it does exist (${axis}
, $axis
, $AXIS
, and ${env.axis}
all fail). I would think it would be shell syntax, which it doesn't seem to be, but regardless it should be either simple or impossible. Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您的 Jenkins 安装在 Windows 上运行吗?
对于每个自定义轴,都会创建一个环境变量。如果您的服务器运行的是 Linux,您可以使用
${axis}
引用您的自定义轴,但在 Windows 上,您必须将其引用为%axis%
Is your Jenkins installation running on Windows?
For each Custom Axis, an environment variable is created. You can refer to your custom axis using
${axis}
if your server is running Linux, but on Windows you must refer to it as%axis%
根据我的经验,
${axis}/pom.xml
应该有效。${axis}/pom.xml
should work in my experience.我很欣赏 OP 以不同的方式解决了这个问题,但为了记录,以下在 Windows 和 Linux 中的 Hudson 中有效。我还没有在 Jenkins 中尝试过:
您需要的语法只是
$axis/pom.xml
我定义了一个
BuildProfile=compile unitTestintegrationTest 的轴
在 Maven 3 配置中(在“高级属性”下),
$BuildProfile/pom.xml
的 POM 文件生成的构建在控制台中给出了以下输出(为简洁起见进行了编辑):
I appreciate that OP has solved this in a different way, but for the record the following works in Hudson in Windows and Linux. I haven't tried it in Jenkins:
The syntax you need for this is simply
$axis/pom.xml
I defined an axis of
BuildProfile=compile unitTest integrationTest
And in the Maven 3 configuration (under Advanced properties) a POM file of
$BuildProfile/pom.xml
The resulting builds gave the following output in the console (edited for brevity):
我们使用 jdk 轴并且只使用 jdk 的名称,所以我认为您可以只使用 axis/pom.xml
We use a jdk axis and just use the name of the jdk so I think you could just use
axis/pom.xml