# parameterized-scheduler-plugin **Repository Path**: mamh-java/parameterized-scheduler-plugin ## Basic Information - **Project Name**: parameterized-scheduler-plugin - **Description**: https://github.com/mamh-java/parameterized-scheduler-plugin - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-05-14 - **Last Updated**: 2025-07-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Parameterized Scheduler [![Jenkins](https://ci.jenkins.io/job/Plugins/job/parameterized-scheduler-plugin/job/master/badge/icon)](https://ci.jenkins.io/job/Plugins/job/parameterized-scheduler-plugin/job/master/) [![Jenkins Plugin](https://img.shields.io/jenkins/plugin/v/parameterized-scheduler.svg)](https://plugins.jenkins.io/parameterized-scheduler) [![GitHub release](https://img.shields.io/github/release/jenkinsci/parameterized-scheduler-plugin.svg?label=changelog)](https://github.com/jenkinsci/parameterized-scheduler-plugin/releases/latest) A Jenkins Plugin to support setting parameters in the build schedule. Using multiple cron lines each ending with a `%` and some `name=value` pairs you can schedule your parameterized build to run with different parameters at different times. ## Installation To install this plugin follow the [Jenkins Plugin installation instructions](https://www.jenkins.io/doc/book/managing/plugins/). ## Configuration After you save your project with some parameters (yes, save, then go back into the config page) you will see >Build periodically with parameters in the *Build Triggers* section as shown here: ![Parameterized Scheduler Config](https://raw.githubusercontent.com/jenkinsci/parameterized-scheduler-plugin/master/site/images/configurationexample.png) ## Configuration Example The cron line before the `%` symbol is processed the same as the jenkins core _Build periodically Schedule_. Leave a space. Put in a `%`. Then add the `name=value` pairs you need for your project build parameters. The idea was born from the need to use a different environment. To use a different TestNG configuration xml. In this example the `env` parameter will be set to int during the build triggered at 15 after each hour. Then `env` will be qa when the build runs at half past. ``` # lets run against the integration environment at 15 past the hour 15 * * * * %env=int # run QA too 30 * * * * %env=qa ``` Yes, of course you can set multiple parameters. Lets say you have three parameters: - furniture - color - name (with a default of fred) Then you might want a schedule like the following: ``` # leave spaces where you want them around the parameters. They'll be trimmed. # we let the build run with the default name 5 * * * * %furniture=chair;color=black # now, let's override that default name and use Mr. Rubble. 10 * * * * %furniture=desk;color=yellow;name=barney ``` ## Declarative Pipeline Configuration Example The parameterized cron trigger can be specified using the key `parameterizedCron` under the [triggers directive](https://jenkins.io/doc/book/pipeline/syntax/#declarative-directives). The built in `cron` trigger is still available and is independent of `parameterizedCron`. Example: ``` pipeline { agent any parameters { string(name: 'PLANET', defaultValue: 'Earth', description: 'Which planet are we on?') string(name: 'GREETING', defaultValue: 'Hello', description: 'How shall we greet?') } triggers { parameterizedCron(''' # leave spaces where you want them around the parameters. They'll be trimmed. # we let the build run with the default name */2 * * * * %GREETING=Hola;PLANET=Pluto */3 * * * * %PLANET=Mars ''') } stages { stage('Example') { steps { echo "${params.GREETING} ${params.PLANET}" script { currentBuild.description = "${params.GREETING} ${params.PLANET}" } } } } } ``` ## Example Output in Jenkins ![Example Output in Jenkins](https://raw.githubusercontent.com/jenkinsci/parameterized-scheduler-plugin/master/site/images/scheduledBuilds.PNG) ## Using the `when` / `triggeredBy` directive One of the options of [when directive](https://www.jenkins.io/doc/book/pipeline/syntax/#when) is a `triggeredBy` clause. When using the built in `cron` trigger, you should use `triggeredBy 'TimerTrigger'`. However, `parameterizedCron` trigger is a different trigger from the built-in one, so the `triggeredBy` should be updated accordingly: ``` pipeline { agent any parameters { string(name: 'PLANET', defaultValue: 'Earth', description: 'Which planet are we on?') string(name: 'GREETING', defaultValue: 'Hello', description: 'How shall we greet?') } triggers { parameterizedCron(''' # leave spaces where you want them around the parameters. They'll be trimmed. # we let the build run with the default name */2 * * * * %GREETING=Hola;PLANET=Pluto */3 * * * * %PLANET=Mars ''') stages { stage('Example') { when { triggeredBy 'ParameterizedTimerTriggerCause' } steps { echo 'This build was triggered by a `parameterizedCron` trigger' } } } } ``` ## Scripted Pipeline Example ``` properties([ parameters([ string(name: 'PLANET', defaultValue: 'Earth', description: 'Which planet are we on?'), string(name: 'GREETING', defaultValue: 'Hello', description: 'How shall we greet?') ]), pipelineTriggers([ parameterizedCron(''' */2 * * * * %GREETING=Hola;PLANET=Pluto */3 * * * * %PLANET=Mars ''') ]) ]) ```