Skip to content

Commit 912dd1a

Browse files
authored
Merge pull request #124 from eplodn/patch-1
Updated the documentation
2 parents 5cf6ebd + 23e49ef commit 912dd1a

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,37 @@ pipeline {
8383

8484
![Example Output in Jenkins](https://raw.githubusercontent.com/jenkinsci/parameterized-scheduler-plugin/master/site/images/scheduledBuilds.PNG)
8585

86+
## Using the `when` / `triggeredBy` directive
87+
88+
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:
89+
90+
```
91+
pipeline {
92+
agent any
93+
parameters {
94+
string(name: 'PLANET', defaultValue: 'Earth', description: 'Which planet are we on?')
95+
string(name: 'GREETING', defaultValue: 'Hello', description: 'How shall we greet?')
96+
}
97+
triggers {
98+
parameterizedCron('''
99+
# leave spaces where you want them around the parameters. They'll be trimmed.
100+
# we let the build run with the default name
101+
*/2 * * * * %GREETING=Hola;PLANET=Pluto
102+
*/3 * * * * %PLANET=Mars
103+
''')
104+
stages {
105+
stage('Example') {
106+
when {
107+
triggeredBy 'ParameterizedTimerTriggerCause'
108+
}
109+
steps {
110+
echo 'This build was triggered by a `parameterizedCron` trigger'
111+
}
112+
}
113+
}
114+
}
115+
```
116+
86117
## Scripted Pipeline Example
87118

88119
```

0 commit comments

Comments
 (0)