I've got a stage in my Jenkinsfile for building from a tag matching a tag name filter:
stage('Build Release from Tag') {
when {
tag '*RELEASE'
}
In order to get tags to be discovered I've had to add tag discovery and a match for the tag name regex and to my pipeline under Branch sources > GitHub
:
The pipeline does discover tags that I push which match the filter. And if I click on one to run a build for it then it does run the build stage that matches the tag conditional. But I was expecting, based on my interpretation of a blogpost, that the build would start automatically as build for branches do.
In the scan repository log I see output such as:
Checking tag TEST0.1.3.RELEASE
‘Jenkinsfile’ found
Met criteria
Changes detected: TEST0.1.3.RELEASE (null → 4aea4ec43c1daf8290ea438ce0bf1a14a6afbc46)
No automatic builds for TEST0.1.3.RELEASE
I also see output in the repository events
log such as Received Push event for tag TEST.0.1.8.RELEASE in repository ryandawsonuk/activiti-build CREATED event
so Jenkins is aware of tags being created. (Which I guess I know already because it discovers them and shows them in the UI, it just doesn't build them unless I manually trigger the build.)
I should say I am using Jenkins-X. As far as I can see this is a Jenkins question and doesn't relate to anything specific to Jenkins-X but I could be overlooking something.
If the pipeline should trigger automatically on tag creation (it seems like Jenkins supports that but I'm not 100% sure) then I'm wondering what additional configuration I could add to trigger the build automatically?
I just needed to read https://issues.jenkins-ci.org/browse/JENKINS-47496 more closely. Tags aren't built automatically by default. You have to install the Basic Branch Build Strategies plugin and activate the building of tags for the pipeline. I did this and now it does build the tags automatically.