-
Notifications
You must be signed in to change notification settings - Fork 248
Trigger runs
Andrew Bayer edited this page Dec 13, 2016
·
7 revisions
Runs of a pipeline are normally triggered by a SCM change. However, you can specify other triggers like a cron-based schedule:
pipeline {
agent any
triggers {
cron '@daily'
}
...
}
This will run the pipeline once per day. The Unix cron style syntax is supported.
Any trigger with a @Symbol
on its class is available - if you put in an invalid trigger name, you'll get a validation error telling you that it's invalid and listing other possible triggers. Noteworthy triggers include:
-
upstream 'project-name,other-project-name', hudson.model.Result.SUCCESS
- run after either of the other projects have built successfully. -
pollSCM '@hourly'
- poll SCM for changes hourly.-
NOTE: this trigger is only properly available in Jenkins 2.22 or later. Previously, it used the
scm
symbol, which did not work due to Pipeline internals.
-
NOTE: this trigger is only properly available in Jenkins 2.22 or later. Previously, it used the
A pipeline, even one that is defined a Jenkinsfile, can also bring in other source repositories as needed.
For example:
pipeline {
agent none
stages {
stage('build') {
agent any
steps {
// run main build here and collect the results via "stashing" for later use
stash includes: 'app/*.py', name: 'stuff'
}
}
stage('testing') {
agent label:'master'
steps {
// use a different repo to get the test suite:
git 'https://github.com/jenkinsci/acceptance-test-harness'
// we unstash our stuff from before (because this may be a different node)
unstash 'stuff'
sh 'run-test-suite.sh'
}
}
}
}
Jenkins will track changes from all repositories you mention this way, and allow the pipeline run to be triggered accordingly.
Documentation
- Getting Started
- Running multiple steps
- Controlling your build environment
- Environment variables
- Reporting test results and storing artifacts
- Notifications
- Deployment and credentials
- Parallelism
- Triggering runs
- Parametrized pipelines
- Pipeline options and log rotation
- Jenkinsfile validation from the CLI
- Advanced pipeline authoring
- Syntax reference
- Version history and changes
Examples