Multibranch Pipeline: Discover tags doesn't automatic build

1,441 views
Skip to first unread message

Sverre Moe

unread,
Jun 13, 2018, 6:05:00 AM6/13/18
to Jenkins Users
I have been thinking about how to release with Gradle without any bump commits like you get with Maven release plugin.

I have changed the multibranch pipeline SCM configuration to Discover tags. It does discover new tags, but it doesn't start an automatic build.

The idea was to manually create the git tag, then Jenkins would discover it and start to build it.

To distinguish in my build script that this is a release build, I am checking that tag name is equal to branch name environment variables.
final def tagName = env.TAG_NAME
final def branchName = env.BRANCH_NAME

def releaseBuild = false
if (branchName.equals(tagName)) {
    releaseBuild
= true
}


It seems it is intended functionality that Jenkins isn't building tags automatically.
The recommended solution is to create a Jenkins branch-api extension plugin that does the trick.

Stephen Connolly suggested three implementations of BranchBuildStrategy.
One for ChangeRequestSCMHead, second for regular branches and the third for TagSCMHead with a timestamp check.


1) There is no option in configuration on Branch Source to add Build strategies. Only Property strategies, unless that is the same thing?
2) Could not find any existing plugins that can add different build strategies.

Steven Foster

unread,
Jun 13, 2018, 6:26:01 AM6/13/18
to Jenkins Users
https://plugins.jenkins.io/basic-branch-build-strategies 
here is a plugin that has an auto-build strategy for tags. Once you add any build strategy, the default auto-build behaviour is disabled so you will need to also add build strategies for branches and PRs as appropriate.

Sverre Moe

unread,
Jun 13, 2018, 7:59:44 AM6/13/18
to Jenkins Users
onsdag 13. juni 2018 12.26.01 UTC+2 skrev Steven Foster følgende:
https://plugins.jenkins.io/basic-branch-build-strategies 
here is a plugin that has an auto-build strategy for tags. Once you add any build strategy, the default auto-build behaviour is disabled so you will need to also add build strategies for branches and PRs as appropriate.

Thanks. That is exactly what I need. 
Reply all
Reply to author
Forward
0 new messages