0

I'm currently using GitLab-CI to CD my project's staging branch to Google Firebase. Each deployment gets a special comment with the PipelineID and Build ID.

firebase deploy -m "Pipeline $CI_PIPELINE_ID, build $CI_BUILD_ID" --non-interactive --token $FIREBASE_DEPLOY_KEY

For ease of use, when rolling back commits in the Firebase console, I'd like to include the commit message into the deploy comment.

I searched through the documentation and didn't find a variable for that. Am I mistaken, or is that really not possible?

Thanks for your help!

Nicolai Schmid
  • 1,022
  • 1
  • 14
  • 29

1 Answers1

10

Gitlab 10.8 and newer:

The $CI_COMMIT_MESSAGE environment variable contains the commit message. Thanks to Ladislav for the update!

Original answer (before gitlab 10.8):

It's definitely not possible through predefined Gitlab CI variables as this list shows. But you may be able to do it some other way.

For instance you could retrieve the commit message using the following (found here)

git rev-list --format=%B --max-count=1 HEAD

or

git rev-list --format=%B --max-count=1 $CI_COMMIT_SHA

And then use the output of that command in your own command.

For instance:

MESSAGE=$(git rev-list --format=%B --max-count=1 HEAD)
firebase deploy -m "Pipeline $CI_PIPELINE_ID, build $CI_BUILD_ID, message $MESSAGE" --non-interactive --token $FIREBASE_DEPLOY_KEY
Jawad
  • 4,457
  • 1
  • 26
  • 29
  • 2
    It is now available in Gitlab 10.8 as `$CI_COMMIT_MESSAGE` environment variable: https://docs.gitlab.com/ce/ci/variables/#predefined-variables-environment-variables – Ladislav Gallay Jun 08 '18 at 06:21