Reputation: 1042
I have a Jenkinsfile as follows
node('workers') {
echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}"
// properties(
// [
// pipelineTriggers([cron('0 * * * *')]),
// ]
// )
stage('checkout') {
checkout scm
}
stage('Build') {
echo 'building'
}
stage('Test') {
echo 'Testing..'
}
stage('Deploy') {
echo 'Deploying....'
}
}
The properties section was not commented out before and I checked it in to test scheduling a Jenkins build from pipeline-as-code. This worked, but now I want to stop the scheduling. Commenting out the code apparently did not work, so how would I go about it?
Upvotes: 7
Views: 7442
Reputation: 61
With declarative pipelines you can use the empty string as the cron schedule to disable.
pipeline {
agent any
triggers {
cron('')
}
stages {
then looking at the job configuration, after the pipeline has run, we see:
No schedules so will never run
Upvotes: 3
Reputation: 5149
For me a call to pipelineTriggers
with an empty list as argument did the trick:
properties([
pipelineTriggers([]),
])
Upvotes: 7