Have ideas to improve npm?Join in the discussion! »

gitlab-build-info

1.1.1 • Public • Published

gitlab-build-info

Grabs GitLab environment variables from the environment

NPM

Build status semantic-release js-standard-style

GitLab CI has a lot of environment variables, see the list. This module collects the relevant ones into a single object that can also generate nice text summary suitable for emails / logs

Install and use

npm i -D gitlab-build-info

While running on GitLab:

const grabGitLabInfo = require('gitlab-build-info')
const {isOnGitLab, collectionInformation} = grabGitLabInfo()
if (isOnGitLab) {
  const info = collectionInformation()
  // info {specName, buildUrl, ...}
}

You can get text summary from the info object

const msg = info.toString()
/*
  returns a string with something like
 
  ==============================
   Build information (GitLab)
  ==============================
  Project name: my-test
  Build spec name: test-spec
  Build ID: 101
  Build URL: https://server.com/user/test/builds/101
  Pipeline ID: 550
  Pipeline URL: https://server.com/user/test/pipelines/550
  Project URL: https://server.com/user/test
*/

Details

See src/index.js for the list of returned properties.

Usually this module checks if there are valid variables on GitLab CI. If you want to skip environment variable checks set environment variable FORCE=1 and the module will return values even if undefined.

Small print

Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2017

License: MIT - do anything with the code, but don't blame me if it does not work.

Support: if you find any problems with this module, email / tweet / open issue on Github

MIT License

Copyright (c) 2017 Gleb Bahmutov <gleb.bahmutov@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Install

npm i gitlab-build-info

DownloadsWeekly Downloads

169

Version

1.1.1

License

MIT

Last publish

Collaborators

  • avatar