Giter VIP home page Giter VIP logo

serverless-plugin-git-variables's Introduction

serverless-plugin-git-variables

Coverage Status Build Status

Expose git variables (HEAD description, branch name, short commit hash, message, git tags, 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, GIT_REPOSITORY, GIT_TAGS) 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

custom:
  gitDescription: ${git:repository} - ${git:branch} - ${git:tags}

functions:
  processEventBatch:
    name: ${self:provider.stage}-${self:service}-process-event-batch
    description: ${self:custom.gitDescription}

  processEventBatch2:
    name: ${self:provider.stage}-${self:service}-process-event-batch-2
    description: ${self:custom.gitDescription}

plugins:
  - serverless-plugin-git-variables

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

Available variables

  • git:repository - name of the git repository
  • git:sha1 - hash of the current commit
  • git:branch - name of the current branch
  • git:isDirty - true if the workspace is currently dirty
  • git:describe / git:describeLight - see below

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.

tags

The tags (${git:tags}) is used to get info about which git tags (separated by comma) are pointing to current commit and if none it will show commit ID as fallback.

Serverless Version Support

  • If you're using serverless 1.12.x or below, use the 1.x.x version of this plugin.
  • This plugin is currently broken for serverless versions between 1.13 and 1.15 (inclusive).
  • If you're using serverless 1.16.x or above, use the >=2.x.x version of this plugin.

Version History

  • 3.4.0
    • Add user name / email (Thanks to @JordanReiter)
    • Add git tag information (Thanks to @navrkald)
  • 3.3.3
    • Update dependencies thanks to dependabot
  • 3.3.2
    • Fixed issue with sporadic command failures (Thanks to @iamakulov)
  • 3.3.1
    • Changed approach for finding repository name, to fix plugin on Windows
  • 3.3.0
    • Added repository name (Thanks to @iDVB)
  • 3.2.0
    • Added a describeLight git variable, which allows use of lightweight tags (Thanks to @domroutley)
  • 3.1.1
    • Fix issue that occurs if a function has no environment specified (Thanks to @arnaudh-nutonomy)
  • 3.1.0
    • Plugin now also adds environment variables that are accessible at runtime (Thanks to @chechu)
  • 3.0.0
    • Add support for long commit hash (Thanks to @e-e-e)
    • backwards incompatible change: git describe now uses --always, so if there are not tags it returns a hash instead of failing (Thanks to @e-e-e)
  • 2.1.1
    • Fix packaging issue
  • 2.1.0
    • Add support for git message (Thanks to @campadrenalin)
  • 2.0.0
    • support Serverless >= 1.16.0
  • 1.0.1
    • list babel-runtime as a dependency
  • 1.0.0
    • Initial release

serverless-plugin-git-variables's People

Contributors

jacob-meacham avatar dependabot[bot] avatar iamakulov avatar domroutley avatar navrkald avatar e-e-e avatar chechu avatar maddiem4 avatar alanning avatar arnaudh-nutonomy avatar idvb avatar jordanreiter avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.