i have 4 repositories in GitLab named Repo1, Repo2, Repo3 and Repo4
now how can i create tag v1.0 for all the Repo's master branch using GitLab api?
Using the POST /projects/:id/repository/tags
create new tag API, the call would be:
curl -X POST "https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/repository/tags?tag_name=v1.0&ref=master&release_description='a short description'&private_token=${GITLAB_TOKEN}"
Replace CI_PROJECT_ID
with your GitLab project id.
As shown in gitlab-org/gitlab
issue 119136, that works for short one-line tag description only.
This creates a lightweight tag.
An annotated tag would need a &message='...'
parameter.
You can see an alternative call here.
After discussion, the OP confirms:
curl -X POST "http://198.x.y.z/api/v4/projects/2345/repository/tags?tag_name=v1.0&ref=master&release_description='first%20tag'&private_token=**************"
(replacing any space with %20
in the release description) works.
it works, but showing
{"tag_name":"v1.5","description":"'first tag'"},"protected":false}
Can I make this protected as true?
That would require another API call.
Example:
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/protected_tags?name=*-stable&create_access_level=30"
With:
create_access_level
: Access levels allowed to create (defaults: 40
, maintainer access level)