Git Product home page Git Product logo

gitlab-cli's Introduction

gitlab-cli

A simple command-line tool to interact with GitLab API. Currently only the version 4 of GitLab API is supported.

Overview

gitlab-cli provides a simple interface to interact with Gitlab servers. It has two main modes:

  • Interactive provides a list of actions to choose from in an interactive way.

  • Command provides a single command line for user actions, arguments and flags.

Supported actions

  • projects
    • get list of projects
    • get a project with id
  • releases
    • get list of releases of a project
    • get a release with project id and tag name
    • create a new release for a project

Authentication

Gitlab authentication is done using Person Access Token. To generate a new token, go to "Gitlab > User Settings > Access Token".

Config file

The Gitlab base url and access token can be stored in a config file. The default location of the config file is $HOME/.gitlab-cli-config.yml. A Sample config file looks like this:

baseUrl: https://gitlabci.example.com
privateToken: 90we48534tgDFf345

Interactive mode

In the interactive mode, gitlab-cli asks user the actions and parameters for each action in an interactive way.

Command mode

In the command mode, user should enter the action and all the necessary arguments and flags together to perform the desired action. Example:

  • gitlab-cli project list --url <gitlab_base_url> --token <your_access_token> to get list of projects
  • gitlab-cli release get --project-id <project_id> --tag-name <tag_name> --url <gitlab_base_url> --token <your_access_token> to get a release with project id and tag name
  • gitlab-cli release create '{"name":"release 0.0.1","tag_name":"0.0.1","description":"A nice description","ref":"master","released_at":"2019-09-12T11:04:05+02:00"}' --url <gitlab_base_url> --token <your_access_token> --project-id <project_id> to create a new release

TODO

  • Other actions can be added. Feel free to create pull requests or issues.
  • Introduce profiles in the config file and receive the active profile as an argument. Example:
server1:
    baseUrl: https://gitlabci.server1.com
    privateToken: 90we48534tgDFf345
server2:
    baseUrl: https://gitlabci.server2.com
    privateToken: 24r58534t2gfg4671
  • Add a new argument to override the location of the config file.

Dev it!

To build:

  • go build -o gitlab-cli

Optionally you can set the version number:

  • go build -o gitlab-cli -ldflags "-X https://github.com/EXXETA/gitlab-cli/cmd.Version=x.y.z"

To test:

  • go test -v ./...

To run:

  • go run gitlab-cli

or

  • ./gitlab-cli

Dependencies

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.