Add build parameter to jenkins build schedule

I have a job with jenkins. I want to build my work at a specific time using the build parameter.

I want to do this using the Build periodically option.

I have this input:

 */1 * * * * Parameter1 

If I do this, jenkins will get an error.

Is this possible without using any plugin .

if not, which plugin will be better

Alternatively, you can specify the parameter here in the schedule?

My actual requirement is this:

  build in morning using one parameter build in evening using another parameter. 
+14
source share
5 answers

Basically, with the Build option, from time to time you cannot schedule Jenkins to work with parameters.

However, in order to schedule a task at different times, which must be used in different environments, you must use the parameterized scheduler plugin as described above https://github.com/jwmach1/parameterized-scheduler or search in (Manage Jenkins → Manage Plugins → Parameterized Scheduler). so it will be #Parameter1 H/15 * * * * %Parameter1 #Parameter2 H/30 * * * * %Parameter2 Remember that you already have parameters, because the plugin is displayed only for tasks with parameters.

The Node and Label parameter plugin can help, as it allows you to select individual nodes, assuming your different qa1 and qa2 servers are already configured. Hope this clarifies you.

+12
source

With native Jenkins crontab this is not possible.

But this should be possible with this plugin: https://github.com/jwmach1/parameterized-scheduler

You have to fork out for a repo and build this plugin + to perform a manual installation.

This guide explains how to create your own plugin: https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial.

(Setting up the environment + Creating a plugin)

+7
source

I am using Jenkins version 2.46.2. I installed the Parameterized Scheduler plugin to periodically run the assembly with another parameter. enter image description here

But the assembly does not start

+1
source

Without plugins, you can try to clone a task and create a build schedule with various parameter values. Those. you can have job_morning and job_evening .

See How do I clone a job at Jenkins?

+1
source

It may not be exactly what you want, but it is an interesting hack, I found out, so I decided to share it. You can programmatically set the Jenkins operating parameters depending on the environment.

 # check if job was trigered by timer if [ $(env | grep -E '^BUILD_CAUSE=TIMERTRIGGER$') ] ; then # your logic here, utilise the power of bash if [ $(date +"%H") -eq 16 ] ; then PARAM=VALUE_1 ; fi if [ $(date +"%H") -eq 17 ] ; then PARAM=VALUE_2 ; fi fi 
0
source

Source: https://habr.com/ru/post/1239804/


All Articles