gitlab-ci.yml `release` group does not recognize env vars which leads to empty release description

Summary

I am trying to improve my release process by automating creating Gitlab releases with the most recent changelog entry (similar to the functionality asked for in this issue: #81). Unfortunately I am unable to extract the changelog information and use it in the release block of my gitlab-ci.yml. While fetching the data works well, the env var that contains it is not recognized by the release:description block, so the description remains empty.

Steps to reproduce

This is my gitlab-ci.yml, changelog.py is a small script that fetches the most recent changelog entry and outputs it to stdout:

release:
  stage: release
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  only:
    - tags
  needs:
    - deploy_prod
  script:
    - echo "running release"
    - apk add python3
    - python3 changelog.py check $CI_COMMIT_TAG && export RELEASE_DESCRIPTION=$(python3 changelog.py get $CI_COMMIT_TAG)
    - echo "$RELEASE_DESCRIPTION"
  release:
    tag_name: $CI_COMMIT_TAG
    description: "$RELEASE_DESCRIPTION"

See the section below for the output of a CI run with this configuration.

Relevant logs and/or screenshots

This is the output of the CI job:

$ python3 changelog.py check $CI_COMMIT_TAG && export RELEASE_DESCRIPTION=$(python3 changelog.py get $CI_COMMIT_TAG)
$ echo "$RELEASE_DESCRIPTION"
* Content of the Changelog\n*An entry here\n* Another one
Executing "step_release" stage of the job script
00:01
$ release-cli create --description "$RELEASE_DESCRIPTION" --tag-name "$CI_COMMIT_TAG"
time="2021-02-08T22:12:16Z" level=info msg="Creating Release..." cli=release-cli command=create name= project-id=xxx ref=xxx server-url="https://gitlab.com" tag-name=0.50.8 version=0.6.0
Tag: 0.50.8
Name: 0.50.8
Description: 
Created At: 2021-02-08 22:12:16.925 +0000 UTC
Released At: 2021-02-08 22:12:16.925 +0000 UTC
See all available releases here: https://gitlab.com/alcemy/test-gitlab-things/-/releases
time="2021-02-08T22:12:17Z" level=info msg="release created successfully!" cli=release-cli command=create name= project-id=xxx ref=xxx server-url="https://gitlab.com" tag-name=0.50.8 version=0.6.0
Cleaning up file based variables
00:01
Job succeeded

Note that the contents of the var $RELEASE_DESCRIPTION are correctly displayed, yet the Description field is empty in the next line.

What is the current bug behavior?

The release description is empty.

What is the expected correct behavior?

The release description contains the changelog entry as specified in the env var.

Output of checks

This bug happens on GitLab.com

Possible fixes

I suspect it has to do with the way that the script block and the calls to release-cli are run in separate shells which don't share the env vars. While there are probably ways to circumvent this using dotenv files or such, this feels too hacky for me.

Edited Feb 14, 2021 by Jaime Martinez
Assignee Loading
Time tracking Loading