Serverless Plugin Git Variables

homepage icon https://github.com/jacob-meacham/serverless-plugin-git-variables
Follow @jacob-meacham

Tracked

NPM Downloads Last Month
5157
Issues
5
Stars
34
Forks
17
Watchers
34
Watch Star Fork Issue Download License NPM Build Status Coverage Status Contributors

Repo README Contents:

serverless-plugin-git-variables

Coverage Status Build Status

Expose git variables (HEAD description, branch name, short commit hash, message, and if the local repo has changed files) to your serverless services. Moreover, it adds GIT related environment variables and tags (GIT_COMMIT_SHORT, GIT_COMMIT_LONG, GIT_BRANCH, GIT_IS_DIRTY) for each defined function in the serverless file. You can disable this by adding the following custom variable in your serverless.yml file:

custom:
  exportGitVariables: false

Usage


functions:
  processEventBatch:
    name: ${self:provider.stage}-${self:service}-process-event-batch
    description: ${git:branch} - ${git:describe} - ${git:sha1}

  processEventBatch2:
    name: ${self:provider.stage}-${self:service}-process-event-batch-2
    description: ${git:describeLight} - ${git:branch}

plugins:
  - serverless-plugin-git-variables

resources:
  Description: >
    ${self:service} ${git:branch}:${git:sha1}
    https://github.com/jacob-meacham/serverless-plugin-git-variables
    ${git:message}

describe and describeLight

The describe (${git:describe}) and the describeLight (${git:describeLight}) variables are both used to return the most recent tag of the repo. However the difference is that whilst describe evaluates to git describe --always, the describeLight variable evaluates to git describe --always --tags. --always will ensure that if no tags are present, the commit hash is shown as a fallback option. (See git describe documentation for more information).

Annotated tags are shown by both describe and describeLight, only describeLight will show lightweight tags (such as those generated when using GitHub’s releases feature).

For more information on annotated and lightweight tags go to the git documentation on tagging.

Serverless Version Support

Version History