44[ ![ Travis CI] ( https://img.shields.io/travis/temando/gitlab-ci-variables-cli.svg )] ( https://travis-ci.org/temando/gitlab-ci-variables-cli )
55[ ![ MIT License] ( https://img.shields.io/github/license/temando/gitlab-ci-variables-cli.svg )] ( https://en.wikipedia.org/wiki/MIT_License )
66
7- CLI tool to allow setting multiple pipeline variables on Gitlab CI, instead of going through Gitlab UI and adding individual variables.
7+ CLI tool to allow setting pipeline variables on Gitlab CI, instead of going through Gitlab UI and adding individual variables.
88
99Supports Gitlab API v4, available since Gitlab 9.0.
1010
@@ -18,6 +18,23 @@ $ npm install -g gitlab-ci-variables-setter-cli
1818
1919## Usage
2020
21+ ### One variable (` glci sv ` )
22+
23+ Run the following command, where:
24+
25+ - ` gitlab-token ` is your Gitlab personal access token
26+ - ` gitlab-project-url ` is your project url on gitlab, e.g. https://gitlab.com/gitlab-org/gitlab-ce
27+ - ` key ` is the variable you want to set
28+ - ` value ` is the value of the variable you want to set
29+
30+ ``` sh
31+ $ glci sv --token < gitlab-token> --url < gitlab-project-url> --key < key> --value < value>
32+ Set < key> = < value> for gitlab-org/gitlab-ce.
33+ Completed setting variable on Gitlab CI.
34+ ```
35+
36+ ### Several variables (` glci sav ` )
37+
2138Put all required variable key/values on a properties file named ` gitlab.env.yml ` , e.g:
2239
2340``` yml
@@ -36,33 +53,40 @@ Run the following command from the directory that contains the properties file,
3653- ` gitlab-project-url` is your project url on gitlab, e.g. https://gitlab.com/gitlab-org/gitlab-ce
3754
3855` ` ` sh
39- $ setAllVars --token <gitlab-token> --url <gitlab-project-url>
56+ $ glci sav --token <gitlab-token> --url <gitlab-project-url>
4057Set AWS_CREDENTIALS = <value> for gitlab-org/gitlab-ce.
4158Set NPM_INSTALL_TOKEN = <value> for gitlab-org/gitlab-ce.
4259Completed setting variables on Gitlab CI.
4360` ` `
4461
45- By default, all existing variables on Gitlab CI will be overridden. If you wish to ignore existing variables, add a `--do-not-force` option, e.g :
62+ # ### For all usages
63+
64+ # #### `--do-not-force`
65+
66+ 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 :
4667
4768` ` ` sh
48- $ setAllVars --token <gitlab-token> --url <gitlab-project-url> --do-not-force
69+ $ glci sav --token <gitlab-token> --url <gitlab-project-url> --do-not-force
4970Skipping AWS_CREDENTIALS, already set for gitlab-org/gitlab-ce.
5071Skipping NPM_INSTALL_TOKEN, already set for gitlab-org/gitlab-ce.
5172Completed setting variables on Gitlab CI.
5273` ` `
5374
54- If your working directory is a git repostory of your project, the `--url` option can be omitted, e.g :
75+ # #### `--url`
76+
77+ If your working directory is a git repository of your project, the `--url` option can be omitted, e.g :
5578
5679` ` ` sh
57- $ setAllVars --token <gitlab-token>
80+ $ glci sv --token <gitlab-token> --key <key> --value <value >
5881No URL specified, using git remote ` origin`.
59- Set AWS_CREDENTIALS = <value> for gitlab-org/gitlab-ce.
60- Set NPM_INSTALL_TOKEN = <value> for gitlab-org/gitlab-ce.
61- Completed setting variables on Gitlab CI.
82+ Set <key> = <value> for gitlab-org/gitlab-ce.
83+ Completed setting variable on Gitlab CI.
6284```
6385
6486> Omitting ` --url ` will derive the URL from the remote named ` origin ` .
6587
88+ ##### ` --token `
89+
6690This project supports ` .gitlabrc ` files using [ rc] ( https://www.npmjs.com/package/rc ) .
6791If ` --token ` is not specified, this project can use a ` .gitlabrc ` , e.g:
6892
@@ -71,20 +95,40 @@ token = this-is-my-gitlab-token
7195```
7296
7397``` sh
74- $ setAllVars --url < gitlab-project-url>
98+ $ glci sav --url < gitlab-project-url>
7599Using token from .gitlabrc.
76100Set AWS_CREDENTIALS = < value> for gitlab-org/gitlab-ce.
77101Set NPM_INSTALL_TOKEN = < value> for gitlab-org/gitlab-ce.
78102Completed setting variables on Gitlab CI.
79103```
80104
81- Essentially, if your project is a git repository, and you have ` .gitlabrc ` file,
82- no options are required and this tool can be invoked simply as:
105+ Alternatively, you can also set a GITLAB_TOKEN environment variable:
106+
107+ ``` sh
108+ $ export GITLAB_TOKEN=this-is-my-gitlab-token
109+ $ glci sv --url < gitlab-project-url> --key < key> --value < value>
110+ Using token from environment variable GITLAB_TOKEN.
111+ Set < key> = < value> for gitlab-org/gitlab-ce.
112+ Completed setting variable on Gitlab CI.
113+ ```
114+
115+ ---
116+
117+ Essentially, if your project is a git repository, and you have a ` .gitlabrc ` file or a GITLAB_TOKEN env variable,
118+ this tool can be invoked simply as:
83119
84120``` sh
85- $ setAllVars
121+ $ glci sav
122+ Using token from .gitlabrc.
86123No URL specified, using git remote ` origin` .
87124Set AWS_CREDENTIALS = < value> for gitlab-org/gitlab-ce.
88125Set NPM_INSTALL_TOKEN = < value> for gitlab-org/gitlab-ce.
89126Completed setting variables on Gitlab CI.
90127```
128+ ``` sh
129+ $ glci sv --key < key> --value < value>
130+ Using token from environment variable GITLAB_TOKEN.
131+ No URL specified, using git remote ` origin` .
132+ Set < key> = < value> for gitlab-org/gitlab-ce.
133+ Completed setting variable on Gitlab CI.
134+ ```
0 commit comments