Giter Site home page Giter Site logo

gitlab-cli's Introduction

NOTICE: This project is no longer maintained. Please check out its successor at https://github.com/NARKOZ/gitlab/

GitLab CLI Tool

Many people prefer to work from the CLI when possible. This tool aims to bring some of the GitLab functionality into the CLI to avoid repeated trips to the web UI.

NOTE

This may not work with GitLab 6.x+. This project is no longer maintained. For a fully-functional, maintained CLI tool look at http://narkoz.github.io/gitlab/

Current version is 2.0.0.

This branch (master) represents current development efforts and may not be 100% stable. Please install via RubyGems and/or checkout tag v2.0.0.

GitLab Versions

This tool has only been tested with the following versions of GitLab. Some or all of the features may or may not work with other versions but they are not officially supported.

  • 5.2.0 - See note below.
  • 5.1.0
  • 5.0.x

Note: 5.2.0 uses a newer version of Grape API framework which caused a regression in all APIs that return raw/blob content. If you are running GitLab 5.2.0, you will need to make a few manual changes to the Gemfile and Gemfile.lock to use GitLab CLI.

1 Stop GitLab

2 Edit 'Gemfile' and modify the 2 lines with Grape:

gem "grape", "~> 0.3.1"
gem "grape-entity", "~> 0.2.0"

3 Edit 'Gemfile.lock' and modify the 2 lines with Grape:

    grape (0.3.2)
      ...<more stuff here>
    grape-entity (0.2.0)

4 To be safe, run bundle install --deployment --without development test postgres or whatever bundle install command is appropriate for your installation.

5 Start GitLab

Now the GitLab CLI tool should work properly with your installation. I am working with GitLab HQ to find a permanent solution to this regression. Thanks for your patience.

Installation and Setup

How do I get started?

Install from rubygems (Recommended)

  1. gem install gitlab_cli

Install from the repo (requires rake and bundler).

  1. Clone the repo.
  2. rake build
  3. rake install (Requires root privileges).

You now have access to the gitlab command.

Required Gems

If you install from rubygems then you will not need to install these required gems yourself. The gem package manager will attempt to install the proper versions for you.

  1. thor >= 0.17.0 and < 0.19
  2. json >= 1.7.7 and < 1.8
  3. rest-client >= 1.6.7 and < 1.7

Required system packages

  1. ruby-devel
  2. make
  3. gcc

How can I find the private token for my user?

Login to your GitLab web UI, go to 'My Profile', and select the 'Account' tab. Copy the private token from the box and paste into your config, which should be located at ~/.gitlab.yml.

How can I add the repo bin path to my environment PATH variable?

Place it in your ~/.bash_profile file. You should end up with something like this: export PATH=$PATH:/path/to/gitlab-cli/repo/bin/

How to use (Commands)

View a list of all the commands you can use to interact with Gitlab CLI, complete with examples.

Commands

Use as a library

Now that Gitlab CLI is distributed as a gem it is increasingly easy to use in your Ruby scripts or applications. Click the link below to see documentation on how to get started using Gitlab CLI as a library.

Use as a library

Issues

If you encounter issues with this project, please find help via one of these avenues.

  1. IRC: #gitlab on Freenode - nick dblessing
  2. GitHub Issues: Open a new issue here on GitHub

Contributing changes

I welcome all contributions. If you would like to include a new feature or bug fix, simply open a pull request and explain the problem or feature you contributed. I will review the contribution at that point. If you want to discuss fixes or improvements before submitting a pull request, please find me on IRC #gitlab on Freenode or open a GitHub issue.

License

See LICENSE file.

gitlab-cli's People

Contributors

chevdor avatar dblessing avatar drewblessing avatar genewoo avatar jiwoong avatar kevinkhill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gitlab-cli's Issues

Strange error if you try to run snippet command on project that isn't accessible

/usr/lib/ruby/1.8/uri/generic.rb:732:in merge': bad URI(is not URI?): #<GitlabCli::Project:0x7f2fefe13810>#<GitlabCli::Project:0x7f2fefe10200>#<GitlabCli::Project:0x7f2fefe0f3f0>#<GitlabCli::Project:0x7f2fefe0e5e0>#<GitlabCli::Project:0x7f2fefe0d7d0>#<GitlabCli::Project:0x7f2fefe0c9c0>#<GitlabCli::Project:0x7f2fefe0ba98>#<GitlabCli::Project:0x7f2fefe0ac38>#<GitlabCli::Project:0x7f2fefe09e00>#<GitlabCli::Project:0x7f2fefe08ff0>#<GitlabCli::Project:0x7f2fefe08140>#<GitlabCli::Project:0x7f2fefe07330>#<GitlabCli::Project:0x7f2fefe064d0>#<GitlabCli::Project:0x7f2fefe056c0>#<GitlabCli::Project:0x7f2fefe048b0>#<GitlabCli::Project:0x7f2fefe03aa0>#<GitlabCli::Project:0x7f2fefe02c68>#<GitlabCli::Project:0x7f2fefe01d68>#<GitlabCli::Project:0x7f2fefe00f30>#<GitlabCli::Project:0x7f2fefe00120>#<GitlabCli::Project:0x7f2fefdff270>#<GitlabCli::Project:0x7f2fefdfe438>#<GitlabCli::Project:0x7f2fefdfd600>#<GitlabCli::Project:0x7f2fefdfc7a0>#<GitlabCli::Project:0x7f2fefdfb990>#<GitlabCli::Project:0x7f2fefdfab80>#<GitlabCli::Project:0x7f2fefdf9d70>#<GitlabCli::Project:0x7f2fefdf8f38>#<GitlabCli::Project:0x7f2fefdf8010>#<GitlabCli::Project:0x7f2fefdf7200>#<GitlabCli::Project:0x7f2fefdf63c8>#<GitlabCli::Project:0x7f2fefdf5540>#<GitlabCli::Project:0x7f2fefdf46e0>#<GitlabCli::Project:0x7f2fefdf38d0>#<GitlabCli::Project:0x7f2fefdf2a70>#<GitlabCli::Project:0x7f2fefdf1c60>#<GitlabCli::Project:0x7f2fefdf0e50>/snippets/21 (URI::InvalidURIError) from /usr/lib/ruby/1.8/uri/common.rb:522:injoin'
from /usr/lib/ruby/1.8/uri/common.rb:521:in each' from /usr/lib/ruby/1.8/uri/common.rb:521:injoin'
from /usr/lib/ruby/gems/1.8/gems/gitlab_cli-2.0.0/lib/gitlab_cli/snippet.rb:22:in get_view_url' from /usr/lib/ruby/gems/1.8/gems/gitlab_cli-2.0.0/lib/gitlab_cli/snippet.rb:14:ininitialize'
from /usr/lib/ruby/gems/1.8/gems/gitlab_cli-2.0.0/lib/gitlab_cli/util/snippets.rb:26:in new' from /usr/lib/ruby/gems/1.8/gems/gitlab_cli-2.0.0/lib/gitlab_cli/util/snippets.rb:26:inget_all'
from /usr/lib/ruby/gems/1.8/gems/gitlab_cli-2.0.0/lib/gitlab_cli/util/snippets.rb:25:in map' from /usr/lib/ruby/gems/1.8/gems/gitlab_cli-2.0.0/lib/gitlab_cli/util/snippets.rb:25:inget_all'
from /usr/lib/ruby/gems/1.8/gems/gitlab_cli-2.0.0/lib/gitlab_cli/cli.rb:62:in snippets' from /usr/lib/ruby/gems/1.8/gems/thor-0.18.1/lib/thor/command.rb:27:insend'
from /usr/lib/ruby/gems/1.8/gems/thor-0.18.1/lib/thor/command.rb:27:in run' from /usr/lib/ruby/gems/1.8/gems/thor-0.18.1/lib/thor/invocation.rb:120:ininvoke_command'
from /usr/lib/ruby/gems/1.8/gems/thor-0.18.1/lib/thor.rb:363:in dispatch' from /usr/lib/ruby/gems/1.8/gems/thor-0.18.1/lib/thor/base.rb:439:instart'
from /usr/lib/ruby/gems/1.8/gems/gitlab_cli-2.0.0/bin/gitlab:4
from /usr/bin/gitlab:19:in `load'
from /usr/bin/gitlab:19

Fix subcommand usage print out

The snippet/project subcommands output incorrect usage information:
"gitlab edit [PROJECT] [SNIPPET_ID]" instead of "gitlab snippet edit [PROJECT] [SNIPPET_ID]".

Implement better error checking

It's unacceptable to exit after an error. This causes all sorts of issues for people using this as a library. Instead, rescue exceptions in the CLI command layer and handle appropriately.

Update docs for 2.0.0

Update docs for 2.0.0 including classes, methods and commands. This will be the last piece to releasing 2.0.0

Don't need to `inspect` snippet content.

In bin/subcommand/snippet.rb I use snippet.inspect. That was necessary before I started using Shellwords.escape in there. Now it adds unnecessary double quotes at the beginning and end of all snippets. Removing it tested fine.

`projects` command only shows 20 projects, no options to paginate

When running GitLab, I see this: (I've obfuscated my project names to protect the innocent

$ ./bin/gitlab projects
1:  lnubb_gi
2:  zvtengvba
3:  pbeqbin_erzbgr
4:  rfca_pbeqbin_naqebvq
5:  hfrefnhehf
7:  encgbe_ncv_grfgre
8:  r3_mrvgren_vbf
9:  urezrfnhehf
10: r3_mrvgren_qrzb_vbf
11: raunaprzrag_eraqrere
13: r3mrvgren_naqebvq
14: r3wf
16: r3nhqvoyrzntvp_naqebvq
17: erfcbafr_ncv_grfgre
18: urezrfnhehf_ncv_grfgre
19: rfn_grfg_unearff_naqebvq
21: rfn_grfg_unearff_vbf
22: erfcbafnqnpgly
23: r3_nhqvoyr_zntvp_vbf
24: tyrr_fgnaqnybar_naqebvq

I have access to 80 projects in GitLab, however. But I don't think there's any way to paginate.

The GitLab API by default only returns 20 objects at a time: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/README.md#pagination

Same install; one works the other doesn't

have it working fine on one ubuntu 14.04 server. the other throws an error:

Unable to get users
undefined method `response' for #<Errno::ECONNREFUSED: Connection refused - connect(2)>

this is driving me nuts. there doesn't seem to be any difference between the two servers. please advise

Add ability to configure output level

Allow user to configure output levels. Levels could be:

  • Debug - Show all output
  • Normal - Show info output plus warnings
  • NoWarn - Show info output and suppress warnings

"405 Method Not Allowed" on User session creation

Hi

Thanks for helping me. I am try to setup a new CI instance for my projects. I cloned the code and done all my setup. Whenever i try to login it says invalid credentials. Upon debugging I got following information:

#<HTTParty::Response:0x10 parsed_response=nil, @response=#<Net::HTTPMethodNotAllowed 405 Method Not Allowed readbody=true>, @headers={"server"=>["nginx"], "date"=>["Mon, 27 Oct 2014 07:36:32 GMT"], "content-type"=>["text/plain"], "transfer-encoding"=>["chunked"], "connection"=>["close"], "status"=>["405 Method Not Allowed"], "allow"=>["OPTIONS, POST"], "cache-control"=>["no-cache"], "x-request-id"=>["d65ded44-b54c-4557-ac36-0f6aab49a288"], "x-runtime"=>["0.003609"]}>

How could avoid this problem? Please help me.

Config Location

I can't seem to find in the docs where to put or how to tell the tool to use my config file with my API key

Add support for global config

Add support for a global config that will merge with the user config. Warn if the user config isn't present. Also add a config that allows suppression of global config warning.

Throw error when passing a invlid project id

gitlab project info gitlab_demo
/Users/jian/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/gitlab_cli-2.0.0/lib/gitlab_cli/util.rb:14:in get_project_id': undefined methodprojects' for GitlabCli::Util:Module (NoMethodError)
from /Users/jian/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/gitlab_cli-2.0.0/lib/gitlab_cli/util/project.rb:6:in get' from /Users/jian/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/gitlab_cli-2.0.0/lib/gitlab_cli/command/project.rb:15:ininfo'
from /Users/jian/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/command.rb:27:in run' from /Users/jian/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/invocation.rb:120:ininvoke_command'
from /Users/jian/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor.rb:363:in dispatch' from /Users/jian/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/invocation.rb:109:ininvoke'
from /Users/jian/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor.rb:232:in block in subcommand' from /Users/jian/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/command.rb:27:inrun'
from /Users/jian/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/invocation.rb:120:in invoke_command' from /Users/jian/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor.rb:363:indispatch'
from /Users/jian/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/base.rb:439:in start' from /Users/jian/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/gitlab_cli-2.0.0/bin/gitlab:4:in<top (required)>'
from /Users/jian/.rbenv/versions/1.9.3-p327-perf/bin/gitlab:23:in load' from /Users/jian/.rbenv/versions/1.9.3-p327-perf/bin/gitlab:23:in

'

Improve error handling for times when Gitlab is not accessible

Currently, if the Gitlab instances specified in the config file is not accessible the user gets a nasty trace:

gitlab-cli/lib/gitlab/util.rb:12:in `projects': undefined method `response' for #<SocketError:0x10d679658> (NoMethodError)
    from /Users/drewb/development/gitlab-cli/bin/gitlab:15:in `projects'
    from /Library/Ruby/Gems/1.8/gems/thor-0.17.0/lib/thor/task.rb:27:in `__send__'
    from /Library/Ruby/Gems/1.8/gems/thor-0.17.0/lib/thor/task.rb:27:in `run'
    from /Library/Ruby/Gems/1.8/gems/thor-0.17.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /Library/Ruby/Gems/1.8/gems/thor-0.17.0/lib/thor.rb:344:in `dispatch'
    from /Library/Ruby/Gems/1.8/gems/thor-0.17.0/lib/thor/base.rb:434:in `start'
    from /Users/drewb/development/gitlab-cli/bin/gitlab:49

Better error messages when options are misplaced or missing

Example:
gitlab snippet add file.txt -t title -n name

Looks ok, right? But it gives a big ugly stack trace. In this case it was simply missing the project ID or name:
gitlab snippet add 13 file.txt -t title -n name

We should give some nicer messages that say something went wrong and here's maybe what happened...

Add create project feature

Per FFForever, it would be nice to have the ability to create a new project and import from a public repo like you can in the UI.

Error "Could not find X command"

Gitlab version: 5.0.1 (Turnkey appliance)
Installed via: "gem install gitlab_cli" command
Created config file in home directory.

When I try to run commands like "gitlab project add test_project" or "gitlab groups" I get the error --> "Could not find X command". It's weird that the command "gitlab projects" works fine though. Any ideas what could it be?

I need gitlab-cli tool to code a script which automates the creation of a couple hundreds of projects in gitlab web ui for my job. I've read the docs and I think this tool is awesome but I cannot make it work properly. Please help.

Create a config file in $HOME folder instead of using config.yml

I'd like to share my setting across folders. Maybe a file in $HOME folder is a much better place to hold it.

Or, we can consider to create custom config in .gitconfig, since every gitlab user is a git User.

BTW, I had a set of scripts on GitLab, maybe I can create several pull requests.

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.