This package has been deprecated

Author message:

Deprecated. Pls use new package gitlab-ci-variables-cli instead

gitlab-ci-variables-setter-cli

2.0.0 • Public • Published

Gitlab CI Variables Setter CLI

NPM Travis CI MIT License

CLI tool to allow setting pipeline variables on Gitlab CI, instead of going through Gitlab UI and adding individual variables.

Supports Gitlab API v4, available since Gitlab 9.0.

Installation

Install the tool globally for ease of use, by running the following command

$ npm install -g gitlab-ci-variables-setter-cli

Usage

One variable (glci sv)

Run the following command, where:

  • gitlab-token is your Gitlab personal access token
  • gitlab-project-url is your project url on gitlab, e.g. https://gitlab.com/gitlab-org/gitlab-ce
  • key is the variable you want to set
  • value is the value of the variable you want to set
$ glci sv --token <gitlab-token> --url <gitlab-project-url> --key <key> --value <value>
Set <key> = <value> for gitlab-org/gitlab-ce.
Completed setting variable on Gitlab CI.

Several variables (glci sav)

Put all required variable key/values on a properties file named gitlab.env.yml, e.g:

AWS_CREDENTIALS: |
    [canary]
    aws_access_key_id = AKIA1234
    aws_secret_access_key = verySecretKey
NPM_INSTALL_TOKEN: 123456789

Note that the value for AWS_CREDENTIALS is a multi line string (with spaces and no tabs).

Run the following command from the directory that contains the properties file, where:

$ glci sav --token <gitlab-token> --url <gitlab-project-url>
Set AWS_CREDENTIALS = <value> for gitlab-org/gitlab-ce.
Set NPM_INSTALL_TOKEN = <value> for gitlab-org/gitlab-ce.
Completed setting variables on Gitlab CI.

For all usages

--do-not-force

By default, existing variables on Gitlab CI will be overridden. If you wish to ignore existing variables, add a --do-not-force option, e.g:

$ glci sav --token <gitlab-token> --url <gitlab-project-url> --do-not-force
Skipping AWS_CREDENTIALS, already set for gitlab-org/gitlab-ce.
Skipping NPM_INSTALL_TOKEN, already set for gitlab-org/gitlab-ce.
Completed setting variables on Gitlab CI.
--url

If your working directory is a git repository of your project, the --url option can be omitted, e.g:

$ glci sv --token <gitlab-token> --key <key> --value <value>
No URL specified, using git remote `origin`.
Set <key> = <value> for gitlab-org/gitlab-ce.
Completed setting variable on Gitlab CI.

Omitting --url will derive the URL from the remote named origin.

--token

This project supports .gitlabrc files using rc. If --token is not specified, this project can use a .gitlabrc, e.g:

token = this-is-my-gitlab-token
$ glci sav --url <gitlab-project-url>
Using token from .gitlabrc.
Set AWS_CREDENTIALS = <value> for gitlab-org/gitlab-ce.
Set NPM_INSTALL_TOKEN = <value> for gitlab-org/gitlab-ce.
Completed setting variables on Gitlab CI.

Alternatively, you can also set a GITLAB_TOKEN environment variable:

$ export GITLAB_TOKEN=this-is-my-gitlab-token
$ glci sv --url <gitlab-project-url> --key <key> --value <value>
Using token from environment variable GITLAB_TOKEN.
Set <key> = <value> for gitlab-org/gitlab-ce.
Completed setting variable on Gitlab CI.

Essentially, if your project is a git repository, and you have a .gitlabrc file or a GITLAB_TOKEN env variable, this tool can be invoked simply as:

$ glci sav
Using token from .gitlabrc.
No URL specified, using git remote `origin`.
Set AWS_CREDENTIALS = <value> for gitlab-org/gitlab-ce.
Set NPM_INSTALL_TOKEN = <value> for gitlab-org/gitlab-ce.
Completed setting variables on Gitlab CI.
$ glci sv --key <key> --value <value>
Using token from environment variable GITLAB_TOKEN.
No URL specified, using git remote `origin`.
Set <key> = <value> for gitlab-org/gitlab-ce.
Completed setting variable on Gitlab CI.

Readme

Keywords

Package Sidebar

Install

npm i gitlab-ci-variables-setter-cli

Weekly Downloads

0

Version

2.0.0

License

MIT

Last publish

Collaborators

  • khoa.q.tran