Triggering a tag-based build with the rest API
I am currently looking if I can trigger a tag build with the API since I have put the tag name in my deployscript and I would like to push the build files into a cloudsmith repository using the tag name as version.
When using the API, I can trigger a rebuild for a tagged version by using commitId="tagname", but the build is still triggered with the corresponding commit id so that the tag name is not known in the environment variables.
I can trick the system into doing a tag build by removing the tag from the gitlab repository and then pushing all tags from a locally cloned repo to recreate it, but I guess I would prefer a API call to trigger it.
I am currently using this script for the API call
$token = '***'
$headers = @{}
$headers['Authorization'] = "Bearer $token"
$headers["Content-type"] = "application/json"
$Body = @{
accountName = "alexlehm"
projectSlug = "veilid"
branch = "main"
commitId = "v0.3.2"
}
$json=$Body | ConvertTo-Json
Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/builds' -Headers $headers -Body $json -Method Post
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Feodor Fitsner on 30 May, 2024 04:08 PM
Hi Alex,
You can pass tag name (and other data) in
environmentVariables
dict of API request: https://www.appveyor.com/docs/api/projects-builds/#start-build-of-b...Let me know if that worked.
2 Posted by alexlehm on 01 Jun, 2024 09:20 AM
Thank you, that works great, I have added an if to evaluate an environment variabe versionId when it is set and pass that instead of the default version, then the commit-id is built and the correct version is passed to the maven upload
3 Posted by alexlehm on 01 Jun, 2024 09:37 AM
I have added the code to the deploy script, it works great
https://github.com/alexlehm/appveyor-config/blob/main/veilid-window...
Support Staff 4 Posted by Feodor Fitsner on 04 Jun, 2024 03:53 AM
Thanks for letting know!
Feodor Fitsner closed this discussion on 04 Jun, 2024 03:53 AM.