Hi,
I wonder can we trigger the build task by detecting is there a new tag in the repo, if yes, then get the code of this tag to do the build? Thanks.
Hi,
I wonder can we trigger the build task by detecting is there a new tag in the repo, if yes, then get the code of this tag to do the build? Thanks.
I am using bitbucket and the repository setting type is git. I saw that it has one setting my related to this, but seems the tag name here is fixed, could we use the regular expression?
It is possible to use webhook to trigger the build for every tag created. I don't know if you are using BitBucket server or bitbucket.org. For how to set webhook, you can refer to below page:
And at QuickBuild side, it looks like below:
and then on the repository page, you can use either TAG
or COMMIT
like below:
Let me know if this can help.
Hi@steveluo ,
Sorry for the slow response, one question is actually for repository setting I am not using Bitbucket Server I am using Git instead, because when I use Bitbucket Server, I will get below error message while the Git setting works. Does the method you replied upper can work with Git configuration also?
Hi@CaoFangyuan,
What I aforementioned can only works with BitBucket Server or BitBucket cloud.
The error occurred is caused by SSL issue. Do you use SSL for your bitbucket server? If you can also use http (not https) to access the bitbucket server, you may try fill in the field RESTful API Url
like below:
Just noticed that the issue should have been fixed in QB 11.0.7. Please either upgrade your QuickBuild to 11.0.7 or later or don't use self-signed certificates in your BitBucket server.
Yes, the recommended/only way is to use webhook if you want to trigger build when tag is created.
Hi@CaoFangyuan ,
With web hooker, it will trigger the quick build when there is a new tag?
Yes. That is the only way if you want to trigger a build whenever the tag is created.
Can I use regular expression to only trigger the quick build if the the tag name matches specific pattern?
Yes. You can use groovy script for field Trigger Condition
. For example, below is to tell QuickBuild only trigger build when tag with prefix REL-
is created:
if (!(delivery.changes.size() > 0 && delivery.changes.get(0).ref.type == "TAG"))
return false;
String tag = delivery.changes.get(0).refId.substring("refs/tags/".length());
return tag.startsWith("REL-");```
Hi@steveluo ,
I tried from myside, the webhook sometimes works well, but sometimes it doesn't work, it seems it triggered but not satisfied with the build condition. I do have one question about the trigger condition in webhook and build condition in general setting, what's the difference between these two? I also tried to get the tag name in build name with script, but seems get the below error, here is my setting:
Another thing is can we achieve that to detect the tag creation of multiple repositories? Once new tag is detected in any one of these repositories, then trigger the quick build.
Hi@CaoFangyuan ,
I just wanna do you use the script I posted before? Do you use the webhook to trigger the build?
If you want to trigger the build only when your tag contains burn
, you may just replace REL-
with burn
like below in your webhook Trigger Condition
field:
if (!(delivery.changes.size() > 0 && delivery.changes.get(0).ref.type == "TAG"))
return false;
String tag = delivery.changes.get(0).refId.substring("refs/tags/".length());
return tag.contains("burn");
The Build Condition
field is for all builds triggered, not matter it is triggered manually, periodically, or by webhook, while what aforementioned script in webhook Trigger Condition
is only for webhook received.
The error in your post means that sometimes the tag
variable is populated and sometimes not. If you only want to trigger the build when tag is created, you needn't set build condition here. Otherwise, you needn't set webhook Trigger Condition
field, instead, you can just pass the tag from webhook to the variable as what I have mentioned in comment #4.