Jenkins多配置项目用户自定义axis环境变量

发布于 2024-12-18 08:51:43 字数 287 浏览 5 评论 0原文

我正在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

今天小雨转甜 2024-12-25 08:51:43

您的 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%

霓裳挽歌倾城醉 2024-12-25 08:51:43

根据我的经验, ${axis}/pom.xml 应该有效。

${axis}/pom.xml should work in my experience.

迷爱 2024-12-25 08:51:43

我很欣赏 OP 以不同的方式解决了这个问题,但为了记录,以下在 Windows 和 Linux 中的 Hudson 中有效。我还没有在 Jenkins 中尝试过:

您需要的语法只是 $axis/pom.xml

我定义了一个 BuildProfile=compile unitTestintegrationTest 的轴

在 Maven 3 配置中(在“高级属性”下),$BuildProfile/pom.xml 的 POM 文件

生成的构建在控制台中给出了以下输出(为简洁起见进行了编辑):

[1.7.0_25] $ C:\Users...\bin\mvn.bat clean install -V -B
-DBuildProfile=compile -f compile/pom.xml

[1.7.0_25] $ C:\Users...\bin\mvn.bat clean install -V -B
-DBuildProfile=unitTest -f unitTest/pom.xml

[1.7.0_25] $ C:\Users...\bin\mvn.bat clean install -V -B
-DBuildProfile=integrationTests -f integrationTests/pom.xml

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):

[1.7.0_25] $ C:\Users...\bin\mvn.bat clean install -V -B
-DBuildProfile=compile -f compile/pom.xml

[1.7.0_25] $ C:\Users...\bin\mvn.bat clean install -V -B
-DBuildProfile=unitTest -f unitTest/pom.xml

[1.7.0_25] $ C:\Users...\bin\mvn.bat clean install -V -B
-DBuildProfile=integrationTests -f integrationTests/pom.xml

思念满溢 2024-12-25 08:51:43

我们使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文