Jenkins Pipeline - wait for non-job items (ComputedFolder, Multibranch Pipeline Project)

28 views
Skip to first unread message

Amedee Van Gasse

unread,
Dec 8, 2020, 10:09:48 AM12/8/20
to Jenkins Users
I'm using multibranch pipelines projects in Jenkins.
I let Jenkins index new branches.
I need Jenkins to wait until indexing of a multibranch pipeline project is complete.

This is my current code:

    def triggerScanMultibranchPipeline(projectDir, repo) {
        def multibranchProject = Jenkins.instance.getItemByFullName "$projectDir/$repo"
        multibranchProject.scheduleBuild()
        while (multibranchProject == null || multibranchProject.isDisabled()) {
            sleep 1000 //1000 milliseconds = 1 second
        }
        sleep time: 1, unit: 'SECONDS'
    }

Already tried:

* change (second) sleep to 30 seconds

This increases duration of the build each time `triggerScanMultibranchPipeline` is called.

I cannot use `"wait: true"` for the indexing to complete, because waiting for non-job items is not supported.

How can I let Jenkins wait until the branch indexing of the Multibranch Pipeline Project is complete?
Reply all
Reply to author
Forward
0 new messages