JenkinsMultibranchPipelineWithGitTagDiscovery

Jenkins Multibranch Pipeline with Git Tag Discovery

Be default Jenkins multibranch pipelines with git won't discover and build tags.

Following on from R Tyler Croy's post about pipelines with git tags.

Here's how you generate a job like that in JobDSL.

The key is that you can't use the obvious branchSources / git API. It's a nice shortcut but it doesn't have a traits property.

ButbranchSources / branchSource / source / git, however, does!

multibranchPipelineJob('my_repo') {
    factory {
        workflowBranchProjectFactory {
            scriptPath('Jenkinsfile')
        }
    }
    branchSources {
        branchSource {
            source {
                git {
                    remote(git_url)
                    credentialsId('my_credential_id')
                    traits {
                        gitBranchDiscovery()
                        gitTagDiscovery()  // be careful you don't create a build storm!
                        headWildcardFilter {
                            includes('my_branch1 my_branches* my_tags* )
                            excludes('')
                        }
                    }
                }
            }
        }
    }
}

$[Get Code]7