Jenkins参数化构建更改默认值 [英] Jenkins parameterized build changing default value

查看:2085
本文介绍了Jenkins参数化构建更改默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jenkins的扩展选择参数" 插件,并希望将构建计划为定期运行,而无需人工干预.

I am using the Jenkins "extended choice parameter" plugin and want to schedule the build to run periodically without human intervention.

从下拉列表中选择构建的参数.

The parameter for the build is selected from a drop down list.

该参数的下拉列表是通过外部脚本生成的,我一直想选择最高的值作为默认值.

The drop down list for the parameter is generated through an external script and I always want to pick the top most value as the default value.

是否可以选择最上面的元素作为计划作业的默认值?

Is there a way to select the top most element as the default value for the scheduled job?

我阅读了一些使用url远程运行作业的方法,但我希望可以通过仅更改作业配置来实现此目的,而不必为此管理单独的脚本.

I read there are ways to run a job remotely using the url but I am hoping that I can achieve this by making changes just to the job configuration so that I don't have to manage a separate script for it.

我的Jenkins实例在Linux上运行,我只想使用Jenkins作业配置的构建触发器->定期构建"部分来运行此作业.

My Jenkins instance is running on Linux and I would like to only run this job using the Build Trigger --> Build Periodically section of a Jenkins job configuration.

推荐答案

好吧,如果您确实只想让计划的作业默认使用最新的,则必须修改用于填充下拉菜单的外部脚本.我不确定您是如何通过外部脚本填充列表的,但是我知道我使用过的方法并且对我来说效果很好.我还使用外部脚本来生成列表,并将该列表存储在文件中. 在您的情况下,情况会有所不同.我们将进一步讨论.

Well, if you really want only the latest to be picked up as default by your scheduled job, you will have to modify the external script that you use to populate the drop-down menu. I'm not sure how you're populating the list through an external script but i know a way which i have used and works perfectly fine for me. I also use an external script to generate a list and i store that list in a file. In your case, things will be a little different. We will discuss that further.

首先,在Extended Choice Parameter中选择以下选项:

First, select the following options in Extended Choice Parameter:

  1. Simple Parameter Types部分中,在Parameter Type

  1. In Simple Parameter Types section, go for Single Select in Parameter Type

代替Choose Source for Value,继续使用Choose Source for Default Value.在这里,选择Default Property File并指定将由外部脚本生成的文件的路径.

Instead of Choose Source for Value, go for Choose Source for Default Value. Here, select Default Property File and specify the path of the file which will be generated by the external script.

由于您只需要从列表中选择最新的,这实际上意味着在存储的文件中仅提供最新的条目就足够了.当您的外部脚本运行并生成列表时,只需将最新文件存储在文件中即可.然后Jenkins会提取此文件,您一切顺利.

Since you have to select only the latest from the list, this effectively means that providing only the latest entry in the stored file should suffice. When your external script runs and generates the list, simply store the latest in the file. This file will then be picked up by Jenkins and you’re good to go.

有关指定Default Property Key的信息,请参考链接.在给定的链接中,我还提供了命令,您可以使用该命令生成Jenkins在加载文件时可以正确解释的格式的文件.这将使您对您的情况有所了解.唯一的不同是,您只需要过滤掉最新的条目,然后将该单个条目存储在文件中.

For specifying Default Property Key, refer this link. In the given link, I have also provided the command with which you can generate the file in a format which will be correctly interpreted by Jenkins while loading the file. That will give you an idea for your case. Only difference in your case will be that you will have to filter out only the latest and then store that single entry in the file.

PS :确保属性文件位于Jenkins Master上(如果是Master-Slave设置).

P.S.: Make sure that the property file is on Jenkins Master (in case of Master-Slave setup).

这篇关于Jenkins参数化构建更改默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆