Changelog generator API always return "No Changes"

Hi there, when running the Changelog generator API (e.g. https://gitlab.com/api/v4/projects/[PROJ_ID]/repository/changelog), I seem to always get “No Changes” no matter what I try, did I do something wrong?

Setup:

  • The repo have tags in X.Y.Z format as specified, the latest tag was 0.4.6
  • .gitlab/changelog_config.yml file is in place
  • There are several new commits in master since 0.4.6
  • Tried the API withg GET method (see below)
  • Tried actual POST method
  • Tried on a diff repo without the changelog config

Results:

  • The rules defined in changelog_config.yml are not followed at all
  • None of the GET curl commands work, all would return “no changes”
  • The POST methods did not work either, also return “no changes”
  • The API call did not work on other repos either

Subset of the commands I tried
curl --header "PRIVATE-TOKEN:TOKEN" "https://gitlab.com/api/v4/projects/[PROJ_ID]/repository/changelog?version=0.4.6"
curl --header "PRIVATE-TOKEN:TOKEN" "https://gitlab.com/api/v4/projects/[PROJ_ID]/repository/changelog?version=0.4.7"
curl --header "PRIVATE-TOKEN:TOKEN" "https://gitlab.com/api/v4/projects/[PROJ_ID]/repository/changelog?version=1.0.0"

curl --header "PRIVATE-TOKEN:TOKEN" "https://gitlab.com/api/v4/projects/[PROJ_ID]/repository/changelog?version=0.4.7&branch=master"
curl --header "PRIVATE-TOKEN:TOKEN" "https://gitlab.com/api/v4/projects/[PROJ_ID]/repository/changelog?version=0.4.7&from=PREVIOUS_COMMITSHA&to=LATEST_COMMIT_SHA"
curl --header "PRIVATE-TOKEN:TOKEN" "https://gitlab.com/api/v4/projects/[PROJ_ID]/repository/changelog?version=0.4.7&from=PREVIOUS_COMMITSHA&to=LATEST_COMMIT_SHA&branch=master"

I found the solution to my issue, it turns out we have to use --trailer feature, which is actually mentioned in the doc, but not included in any examples.

Here’s one basic way to concept-proof this from start to finish:

  1. make code changes
  2. make sure tags follow the X.Y.Z format
  3. config template to read feature (or whatever string you define) as a category as shown in doc here
  4. IMPORTANT: commit changes with trailer git commit -m "message to appear in changelog" --trailer "Changelog: feature"
  5. run the changelog API like so: curl --header "PRIVATE-TOKEN:[TOKEN]" "https://gitlab.com/api/v4/projects/[PROJ_ID]/repository/changelog?version=[LATEST_VERSION]"

It would be really nice if Merge Request merges auto-add the title of the MR as a Changelog trailer. I hope there is a way to implement this as a template or an option or something. Otherwise how can we ensure that the appropriate trailer makes its way in at the right time? It’s always when the code is merged that is the right time.

Is it possible to use the API without a trailer? we are using conventional commits in our projects, but without trailers.

1 Like

Not at the time I tried it, but that was like more than a year ago, things could’ve changed since then, you can just try it quick, create a few tags, create a config file, & run the curl commands

yes i already tried that. didn’t work… :frowning:

1 Like

We had exactly same issue and we ended up writing a small CLI tool to address this. Here it is:

We too dont use trailers in the commits. What the CLI tool does is categorize the MRs in the changelog based on their labels which works pretty well for us. If you are interested in checking it out, we would be interested in your feedback! Cheers!

for the step 3 “config template to read feature” how do you exactly do that?

You have to create a yml template file with name changelog_config.yml under .gitlab folder

See doc here on config template: Changelogs | GitLab