Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add build parameter in jenkins build schedule

Tags:

I have a jenkins job. i want to build my job in a specific time with a build parameter.

I want to do this by using the Build periodically option.

I have input like this:

*/1 * * * * Parameter1 

If I do this, jenkins show an error.

Is this possible without using any plugin.

if not, than which plugin will be better

Alternatively is there a way to give parameter's here in the schedule?

My actual requirement is like this:

 build in morning using one parameter  build in evening using another parameter.     
like image 276
Eric Ipsum Avatar asked Jan 04 '16 15:01

Eric Ipsum


People also ask

How do I schedule a build in Jenkins with parameters?

Basically, with the 'Build periodically' option you can't schedule a Jenkins job with parameters. However, to schedule a job at different times that needs to use different environments, you have to use the parameterized-scheduler plugin or search for it in (Manage Jenkins -> Manage Plugins -> Parameterized Scheduler).

How do I add build parameters in Jenkins?

Defining Build Parameters Any Jenkins job or pipeline can be parameterized. All we need to do is check the box on the General settings tab, “This project is parameterized”: Then we click the Add Parameter button.

What is build with parameters in Jenkins?

Allows the user to provide parameters for a build in the url, prompting for confirmation before triggering the job. The plugin exposes $JENKINS/job/$JOB/parambuild url to trigger the build with parameter.

How do I schedule a Jenkins build?

Press the "Schedule Build" link on the project page or use the schedule build action in the list view. Then select date and time when to schedule the build. The build will be added to the build queue with the respective quiet period.


2 Answers

Basically, with the 'Build periodically' option you can't schedule a Jenkins job with parameters.

However, to schedule a job at different times that needs to use different environments, you have to use the parameterized-scheduler plugin or search for it in (Manage Jenkins -> Manage Plugins -> Parameterized Scheduler).

Examples:

 # Parameter1  H/15 * * * * %Parameter1  # Parameter2  H/30 * * * * %Parameter2 

Remember you have to have your parameters already setup because the plugin is visible only for jobs with parameters.

The Node and Label parameter plugin can help since it allows you to select individual nodes assuming your different servers qa1 and qa2 are already configured. Hope that clarifies things for you.

like image 191
Claudio A Avatar answered Sep 17 '22 19:09

Claudio A


With the native Jenkins crontab, it's not possible.

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

You have to fork the repo and build this plugin + do a manual installation.

This tutorial explains how to build a custom plugin: https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial

(Setting Up Environment + Building a Plugin)

like image 36
Bruno Lavit Avatar answered Sep 19 '22 19:09

Bruno Lavit