Gitlab how to comment the release in the CI?

Viewed 709

I have a maven project that I build using gitlab. When a tag is created, I run 'mvn package'. This create a jar, that is then copy and launch on the server. -> All this works well.

Now I would like to add automatically in the release note, all the commits that occurs between this tag and the previous tag, so that I know what is deployed in this tag.

How I can do that during the CI ?

2 Answers

I made it work like this:

# create release note
    - >- 
        curl --request POST 
        -H "PRIVATE-TOKEN: ${GITLABAPI_TOKEN}" 
        -H 'Content-Type: application/json' 
        --data "{\"description\": \"`git log $(git tag --sort version:refname | tail -n 2 | head -n 1)..$(git tag --sort version:refname | tail -n 1) --oneline | sed '$!s/$/<br>/' | tr -d '\n'`\"}"
        https://gitlab.unc.nc/api/v4/projects/${APP_GITLAB_NUMBER}/repository/tags/${CI_COMMIT_TAG}/release

This update the release note of the tag, with all commits that occurs between the 2 last commits.

You might consider including the git-commit-id/maven-git-commit-id-plugin plugin to your pom.xml for the building process through GitLab-CI.

That would allow to generate and include a properties file with all the relevant version information to your jar.
That does not include the release notes, though, which would still need to be generates and included separately, but that plugin shows you how it is done.

Related