jenkins trigger build if new tag is released

2019-01-10 17:39发布

I want to configure jenkins so that it starts building if a new tag is released in any branch of an git repository. How do I configure this behaviour?

I'm very new in jenkins so excuse me if this might be a very basic question but I couldn't find it out on myself.

git jenkins config

Triggering: build trigger

Thanks for any help

标签: git jenkins tags
3条回答
啃猪蹄的小仙女
2楼-- · 2019-01-10 17:41

Please note that the approach in the answer provided by stanjer doesn't make Jenkins trigger builds on new tags if they point to commits that were built before. For example, you tag release v1.0.0 (to make jenkins deploy this release), then on the future you have to rollback to v1.0.0, tagging its commit again, but with v1.0.0-rollback, Jenkins won't deploy your rollback because it will check the hash the tag points to, not the hash of the tag itself.

In summary, jenkins will only build new tags if they point to commits that are not tagged already, and this is currently not tweakable.

It would be awesome if one could use Jenkins as a CD tool working with tags for deploys and rollbacks.

More info here https://groups.google.com/forum/#!msg/jenkinsci-users/mYxtDNMz1ZI/xbX9-xM9BQAJ

查看更多
做个烂人
3楼-- · 2019-01-10 17:52

Set refspec to: +refs/tags/*:refs/remotes/origin/tags/*

branch specifier: **

Under build triggers check Build when a change is pushed to GitHub

查看更多
叼着烟拽天下
4楼-- · 2019-01-10 18:04

What do you mean by new tag? Does it has some template name?

You can surely define it in Advanced --> Refspec -->refs/tags/{tagname} .

You can even do refs/tags/* for finding really ANY new tags.

enter image description here

查看更多
登录 后发表回答