Trigger a build for a git tag using the API

I’m trying to trigger a build using the API (https://docs.travis-ci.com/user/triggering-builds/), but instead of triggering it for a branch, I want to trigger it for a tag. I tried setting "tag": "v2.1.0" in the request, but that just triggers a build for the master branch. Is there any way to trigger a build for a tag instead? Thanks.

You can pass the tag to branch:

body='{
  "request": {
    "branch":"any_tag_you_want"
  }
}'

Thanks. I just tried that, but Travis still treats it as a branch and not as a tag. Explicitly specifying TRAVIS_TAG as well did the job though. For reference, here’s my (working) request:

{
	"request": {
		"branch": "v2.1.0",
		"config": {
			"merge_mode": "deep_merge",
			"env": [
				"TRAVIS_TAG=v2.1.0"
			]
		}
	}
}
1 Like
Imprint