Tech /

Jenkins Multibranch Pipeline With Git Tag Discovery





edit SideBar

Jenkins Multibranch Pipeline With Git Tag Discovery

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.

But branchSources / 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('
')
                        }
                    }
                }
            }
        }
    }
}
Recent Changes (All) | Edit SideBar Page last modified on 08 March 2019, at 06:17 PM UTC Edit Page | Page History
Powered by PmWiki