简体   繁体   English

Jenkins构建 - 参数化maven目标

[英]Jenkins builds - parameterized maven goals

In Jenkins I have a "parameterized build". 在Jenkins,我有一个“参数化构建”。

I click "This build is parameterized". 我单击“此构建已参数化”。 Then add "Choice parameter": 然后添加“选择参数”:

SELECT_TARGET=install -DskipTests=true
SELECT_TARGET=install
SELECT_TARGET=clean install

in Build option - Goals and options : ${SELECT_TARGET} 在构建选项中 - 目标和选项:$ {SELECT_TARGET}

Then Build With parameter, it failed with 然后使用Build With参数,它失败了

[ERROR] Unknown lifecycle phase "${SELECT_TARGET}". [错误]未知生命周期阶段“$ {SELECT_TARGET}”。 You must specify a valid lifecycle phase or a goal in the format 您必须以格式指定有效的生命周期阶段或目标

In https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build . https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build中

Open issues 开放式问题

How can i pass the configured parameter to the maven execution of the build? 如何将配置的参数传递给构建的maven执行? Eg I've got a maven build and a specific profile should be given as a String parameter in the Jenkins build. 例如,我有一个maven构建,并且应该在Jenkins构建中将一个特定的配置文件作为String参数给出。

How can I make it work? 我怎样才能使它工作?

Update : 更新:

I played with Jenkins plugins and settings, I think Jenkins has a miss-configuration. 我玩Jenkins插件和设置,我认为Jenkins有一个错过配置。

How I made it work: 我是如何工作的:

  1. Use Extensible choice plugin 使用可扩展选择插件
  2. Remove "SELECT_TARGET=" 删除“SELECT_TARGET =”
  3. use $SELECT_TARGET as Pointed out in comment. 使用$ SELECT_TARGET作为注释中的指出。

And it worked. 它奏效了。 Thanks for the help. 谢谢您的帮助。

To achieve this you can simply 要做到这一点,你可以简单

  • tick the parameterized build flag 勾选参数化构建标志
  • create a choice named eg SELECT_TARGET with the values you want to choose from (the first one being the default) 创建一个名为SELECT_TARGET ,其中包含您要选择的值(第一个是默认值)
install
install -DskipTests=true
clean install
  • Use $SELECT_TARGET (or which ever name you have chosen) in your build goals. 在构建目标中使用$SELECT_TARGET (或您选择的名称)

There is no need for any plugins. 不需要任何插件。 Note that this works for every thing you want to configure - that's the target of parameterized builds 请注意,这适用于您要配置的所有内容 - 这是参数化构建的目标

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM