Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create tag automatically upon accepted merge request in GitLab?

Tags:

gitlab

tags

This is for a repository containing a library. The library version number is increment (manually) each time a Merge Request to master is accepted.

However, if a want to access a file from version X.Y.Z, I have to look for the commit that incremented the version number to X.Y.Z, get its date, and then look in the history of the file for the version at that date.

I would like to create a tag per version, automatically when the Merge Request to master was created. Is this possible ?

I hoped it would be possible with the new GitLab slash commands, but there currently is not support for tags.

Is there any other possibility than using web hooks ?

like image 932
philant Avatar asked Aug 26 '16 06:08

philant


2 Answers

While facing the same challenge, I stumbled upon this suggestion on GitLab's former issue tracker on GitHub1:

“You can write up a script to use GitLab API to accept a merge request, get the commit of the merge and then tag that commit.” --MadhavGitlab

(just to mention that — for me that's not sufficient)


1 EDIT: Looks like all issues have been purged from the GitHub mirror, so this link does no longer work, but luckily the relevant quote persists right here.

like image 56
klaus Avatar answered Sep 27 '22 20:09

klaus


I first tried to do it the gitlab way, by creating a .gitlab-ci.yml file in the project top-level directory. That file can contain the commands creating the version tag. The user executing the script has to have enough permission to push to the git project, and be configured with authoring information.

I finally did it on a Jenkins server, where I created a job that is invoked when commits are pushed into a specific branch. The tag can be created in the execute shell commands.

like image 42
philant Avatar answered Sep 27 '22 22:09

philant