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

383 Views Asked by At

I'm using multibranch pipeline projects in Jenkins. I let Jenkins index new branches. I need Jenkins to wait until the 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 the 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. See https://github.com/jenkinsci/pipeline-build-step-plugin/blob/pipeline-build-step-2.13/src/main/java/org/jenkinsci/plugins/workflow/support/steps/build/BuildTriggerStepExecution.java#L80

How can I let Jenkins wait until the branch indexing of the Multibranch Pipeline Project is complete?

0

There are 0 best solutions below