Lenny
Lenny

Reputation: 398

How to enable concurrent build from Jenkins pipeline

Are there any Jenkins properties to enable concurrent builds from within a pipeline? My pipeline disables concurrent builds for one node with properties([disableConcurrentBuilds()]) and I would like to re-enable it when run on a different node.

I have tried properties([enableConcurrentBuilds()]) and properties([concurrentBuild()]) but both are invalid options.

Upvotes: 3

Views: 9662

Answers (4)

Emre Uslu
Emre Uslu

Reputation: 11

Concurrent builds are enabled by default but if you use disableConcurrentBuild in your pipeline then it will be disabled. You can just use empty properties block as:

properties([])

Then the concurrent builds will be re-enabled.

Upvotes: 1

Varunkumar Reddy
Varunkumar Reddy

Reputation: 1

1

pipeline {
    agent none

    stages {
        stage('sleep') {
            agent any
            options {
                throttle(['test_4'])
            }
            steps {
                sh "sleep 500"
                echo "Done"
            }
        }
    }
}

Upvotes: 0

rad
rad

Reputation: 11

While concurrent builds are enabled by default; during the pipeline execution it would be much more flexible having the ability to disable/enable concurrency.

e.g. if some specific stages may not allow concurrency but all remaining stages do.

Upvotes: 1

brianrobt
brianrobt

Reputation: 427

Concurrent builds are enabled by default. That is why the is the disableConcurrentBuilds() function. So there is no need to add any additional code to your pipeline to enable concurrent builds.

Upvotes: 0

Related Questions