gitlab-env

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2025 License: MIT Imports: 12 Imported by: 0

README

Gitlab Env

A handy tool to export and import a large number of CICD environment variables.

Command usage:

go install github.com/quangthe/gitlab-env@latest

gitlab-env -h
gitlab-env export -h
gitlab-env import -h

Export Gitlab project env vars

gitlab-env export \
  --gitlab-token "your-gitlab-token" \
  --gitlab-host "gitlab.example.com"  \
  --project-id "55" \
  --output-file gitlab.json

By default, the command will query the gitlab project variable with --page-number=1, --page-size=100

Tips: Use --export-all=true flag to export all project env vars.

Filter by environment scopes --env-scopes:

gitlab-env export \
  --gitlab-token "your-gitlab-token" \
  --gitlab-host "gitlab.example.com"  \
  --project-id "55" \
  --env-scopes "*,dev,prod" \
  --output-file gitlab.json

The gitlab.json file will look like this

[
  {
    "variable_type": "env_var",
    "key": "FORM_URL",
    "value": "jdbc:postgresql:\\/\\/shared-database:5432\\/forms",
    "protected": true,
    "masked": false,
    "raw": true,
    "environment_scope": "*",
    "description": ""
  },
  {
    "variable_type": "env_var",
    "key": "POLL_URL",
    "value": "jdbc:postgresql:\\/\\/shared-database:5432\\/polls",
    "protected": true,
    "masked": false,
    "raw": true,
    "environment_scope": "*",
    "description": ""
  }
]

Import env vars into Gitlab project

gitlab-env import \
  --gitlab-token "your-gitlab-token" \
  --gitlab-host "gitlab.example.com"  \
  --project-id "56" \
  --input-file gitlab.json

By default, the import command does not filter on the Environment Scope. Use --env-scopes flag to only import env vars with selected scopes. Example: --env-scopes "*,dev,prod" will import env vars with scope *, dev and prod.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL