Git Product home page Git Product logo

glt's Introduction

glt

pipeline status coverage report npm Commitizen friendly semantic-release Renovate enabled

https://gitlab.com/nickshine/glt

A command-line interface for GitLab tasks.


Install

npm install -g glt

# or
npx glt

Usage

glt

Usage: glt [options] [command]

A cli for GitLab tasks

Options:
  -V, --version  output the version number
  -h, --help     output usage information

Commands:
  ci             perform GitLab CI tasks
  env            perform tasks on GitLab environments
  help [cmd]     display help for [cmd]

glt ci

Usage: glt-ci [options] [command]

perform GitLab CI tasks

Options:
  -h, --help  output usage information

Commands:
  cancel      cancel pipelines
  help [cmd]  display help for [cmd]

glt env

Usage: glt-env [options] [command]

perform tasks on GitLab Environments

Options:
  -h, --help  output usage information

Commands:
  clean       clean environments
  stop        stop environments
  help [cmd]  display help for [cmd]

Tasks

glt ci cancel

โžœ  glt ci cancel --help

Usage: glt-ci-cancel [options]

cancel pipelines

Options:
  -u, --url <url>         GitLab instance (default: '$GITLAB_URL' || 'https://gitlab.com')
  -t, --token <token>     GitLab Personal Access Token used to authenticate with the API (default: '$GITLAB_TOKEN'|| '$CI_JOB_TOKEN')
  -v, --verbose           make the operation more talkative
  -p, --project-id <id>   GitLab project id (default: '$CI_PROJECT_ID')
  -i, --pipeline-id <id>  cancel pipelines before pipeline id <id> (default: '$CI_PIPELINE_ID')
  -b, --ref <ref>         only look at pipelines on branch <ref> (default: '$CI_COMMIT_REF_NAME' || 'master')
  -h, --help              output usage information

Description: cancel any previously-running pipelines on the given branch. This task is intended to be run in a GitLab CI pipeline to reference CI_PIPELINE_ID as the currently running pipeline.

Use Case: GitLab CI currently (as of 11.x) only has the option to auto-cancel pending non-HEAD pipelines on a branch. This task is useful for controlling runner availability for redundant running pipelines on a branch.

glt env clean

Usage: glt-env-clean [options]

clean environments (delete environments with zero deployments)

Options:
  -u, --url <url>        GitLab instance (default: '$GITLAB_URL' || 'https://gitlab.com')
  -t, --token <token>    GitLab Personal Access Token used to authenticate with the API (default: '$GITLAB_TOKEN'|| '$CI_JOB_TOKEN')
  -v, --verbose          make the operation more talkative
  -p, --project-id <id>  GitLab project id (default: '$CI_PROJECT_ID')
  -h, --help             output usage information

Description: remove any existing environments that are "empty" (environments with zero deployments).

Use Case: Projects that have optional pipelines configured (with a manual play button trigger) will generate empty environments for each commit pushed that is not executed/deployed, creating lots of "empty" environments that need to be deleted.

glt env stop

Usage: glt-env-stop [options]

stop environments with deployments older than a specified age

Options:
  -u, --url <url>        GitLab instance (default: '$GITLAB_URL' || 'https://gitlab.com')
  -t, --token <token>    GitLab Personal Access Token used to authenticate with the API (default: '$GITLAB_TOKEN'|| '$CI_JOB_TOKEN')
  -v, --verbose          make the operation more talkative
  -p, --project-id <id>  GitLab project id (default: '$CI_PROJECT_ID')
  -a, --age <age>        stop environmments with deployments older than <age> (default: "1w")
  -h, --help             output usage information

Description: stop environments that only have deployments older than a specified age.

Use Case: Projects utilizing dynamic environments via the Gitlab Review Apps feature may need to control environment quotas by forcing an environment of a certain age to be stopped and cleaned up.

Examples

Cancel Redundant Pipelines From GitLab CI

In a GitLab CI pipeline, the following example will use GitLab Predefined environment variables to cancel any redundant running pipelines before executing tests. Running pipelines older than CI_PIPELINE_ID on project CI_PROJECT_ID for the the current branch CI_COMMIT_REF_NAME will be canceled using a provided Personal Access Token set on environment variable GITLAB_TOKEN.

image: node:10

stages:
  - test

variables:
  GITLAB_TOKEN: $ACCESS_TOKEN       # ACCESS_TOKEN stored in project env vars

test:
  stage: test
  script:
    - npx glt ci cancel -v
    - npm install
    - npm run test
Cancel Running Pipelines

This example cancels all running pipelines on a branch my-branch for a project at https://gitlab.com. This is run outside of a GitLab CI pipeline, using the command-line flags:

TOKEN=<personal access token>
PROJECT_ID=<project id from gitlab.com>


npm install -g glt

glt ci cancel -t $TOKEN -p $PROJECT_ID -b my-branch -v
Stop Environments Older than One Week From GitLab CI

In a GitLab CI pipeline, the following example will stop environments with no deployments younger than 1 week old on project CI_PROJECT_ID using a provided Personal Access Token set on environment variable GITLAB_TOKEN.

image: node:10

stages:
  - test

variables:
  GITLAB_TOKEN: $ACCESS_TOKEN       # ACCESS_TOKEN stored in project env vars

deploy:
  stage: deploy
  script:
    - npx glt env stop -a 1w
    - kubectl apply -f deployment.yaml

Contributing

Contributions are welcome! Help add tasks to glt! See the Contributing Guide.

glt's People

Contributors

dependabot[bot] avatar nickshine avatar renovate-bot avatar semantic-release-bot avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

y0zg

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.