65854

Jenkins parameterized build changing default value

Question:

I am using the Jenkins <strong>"extended choice parameter"</strong> 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?

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.

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.

Answer1:

Well, if you really want only the latest to be picked up as default by your <em>scheduled</em> 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. <em>In your case, things will be a little different</em>. We will discuss that further.

First, select the following options in Extended Choice Parameter:<br />

<ol><li>

In Simple Parameter Types section, go for Single Select in Parameter Type<br />

</li> <li>

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.

</li> </ol>

<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/5ypxE.png" data-original="https://i.stack.imgur.com/5ypxE.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Since you have to select only the latest from the list, this effectively means that <em>providing only the latest entry in the stored file should suffice</em>. 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.

For specifying Default Property Key, refer <a href="https://stackoverflow.com/questions/25640028/select-branch-to-build-in-jenkins/25642499#25642499" rel="nofollow">this</a> 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 <em>single</em> entry in the file.

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

Recommend

  • swift + OS X sandboxing: treat 'NSVBOpenPanel' as a 'NSOpenPanel' :: because I n
  • How to create CRITICAL events for Windows Event Viewer?
  • Installing Google Web Toolkit Developer Plugin
  • CUDA Debugging - VS on windows workstation, GPUs on Linux server?
  • SSIS Designer is running VERY slowly
  • How to add the custom button on google's(device) native application in android?
  • Portable JRE on Linux - possible?
  • Compare struct to a constant in C
  • Django Haystack Rebuild Index
  • How can I replace the server in Web Component Tester
  • uml Composition relationships to RDF and OWL
  • Azure table store snapshot/backup capability
  • Spring Cloud Microservice Architecture Confusion
  • Tamper-proof configuration files in .NET?
  • xtable package: Skipping some rows in the output
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • Exception “firebase.functions() takes … no argument …” when specifying a region for a Cloud Function
  • Highlight one bar in a series in highcharts?
  • How can I send an e-mail from a vbs script
  • Change JButton Shape while respecting Look And Feel
  • Fetching methods from BroadcastReceiver to update UI
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Javascript + PHP Encryption with pidCrypt
  • ActionScript 2 vs ActionScript 3 performance
  • How can I estimate amount of memory left with calling System.gc()?
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • Apache 2.4 - remove | delete | uninstall
  • WOWZA + RTMP + HTML5 Playback?
  • Calling of Constructors in a Java
  • Circular dependency while pushing http interceptor
  • Is there a mandatory requirement to switch app.yaml?
  • PHP: When would you need the self:: keyword?
  • Proper folder structure for lots of source files
  • AngularJs get employee from factory
  • How to set the response of a form post action to a iframe source?
  • coudnt use logback because of log4j
  • Change div Background jquery
  • How does Linux kernel interrupt the application?
  • UserPrincipal.Current returns apppool on IIS