A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.rubydoc.info/gems/gitlab/frames below:

README – Documentation for gitlab (6.0.0) – RubyDoc.info

Gitlab

website | documentation | gitlab-live

Gitlab is a Ruby wrapper and CLI for the GitLab API.

Installation

Install it from rubygems:

gem install gitlab

Or add to a Gemfile:

gem 'gitlab'

Mac OS users can install using Homebrew (may not be the latest version):

brew install gitlab-gem
Usage

Configuration example:

Gitlab.configure do |config|
  config.endpoint       = 'https://example.net/api/v4' 
  config.private_token  = 'qEsq1pt6HJPaNciie3MG'       
  
  
  
  
end

(Note: If you are using GitLab.com's hosted service, your endpoint will be https://gitlab.com/api/v4)

Usage examples:


Gitlab.endpoint = 'https://example.net/api/v4'



Gitlab.private_token = 'qEsq1pt6HJPaNciie3MG'



Gitlab.http_proxy('proxyhost', 8888)

Gitlab.http_proxy('proxyhost', 8888, 'proxyuser', 'strongpasswordhere')

ENV['GITLAB_API_HTTPARTY_OPTIONS'] = '{read_timeout: 60}'


Gitlab.projects(per_page: 5)



g = Gitlab.client(
  endpoint: 'https://example.com/api/v4',
  private_token: 'qEsq1pt6HJPaNciie3MG',
  httparty: {
    headers: { 'Cookie' => 'gitlab_canary=true' }
  }
)



user = g.user



user.email



Gitlab.sudo = 'other_user'



Gitlab.sudo = nil



Gitlab.private_token = ''



projects = Gitlab.projects(per_page: 5)


projects.has_next_page?


projects.next_page


projects.auto_paginate do |project|
  
end


projects.auto_paginate

For more information, refer to documentation.

CLI

It is possible to use this gem as a command line interface to GitLab. In order to make that work you need to set a few environment variables:

export GITLAB_API_ENDPOINT=https://gitlab.example.com/api/v4
export GITLAB_API_PRIVATE_TOKEN=<your private token from /profile/personal_access_tokens>

# This one is optional and can be used to set any HTTParty option you may need
# using YAML hash syntax. For example, this is how you would disable SSL
# verification (useful if using a self-signed cert).
export GITLAB_API_HTTPARTY_OPTIONS="{verify: false}"

Usage:

When you want to know which CLI commands are supported, take a look at the client commands implemented in this gem. Any of those methods can be called as a command by passing the parameters of the commands as parameters of the CLI.

Usage examples:

# list users
# see: https://www.rubydoc.info/gems/gitlab/Gitlab/Client/Users#users-instance_method
gitlab users

# get current user
# see: https://www.rubydoc.info/gems/gitlab/Gitlab/Client/Users#user-instance_method
gitlab user

# get a user
# see: https://www.rubydoc.info/gems/gitlab/Gitlab/Client/Users#user-instance_method
gitlab user 2

# filter output
gitlab user --only=id,username

gitlab user --except=email,bio

# get a user and render result as json
gitlab user 2 --json

# passing options hash to a command (use YAML)
# see: https://www.rubydoc.info/gems/gitlab/Gitlab/Client/MergeRequests#create_merge_request-instance_method
gitlab create_merge_request 4 "New merge request" "{source_branch: 'new_branch', target_branch: 'master', assignee_id: 42}"

CLI Shell

Usage examples:

# start shell session
gitlab shell

# list available commands
gitlab> help

# list groups
gitlab> groups

# protect a branch
gitlab> protect_branch 1 master

# passing options hash to a command (use YAML)
gitlab> create_merge_request 4 "New merge request" "{source_branch: 'new_branch', target_branch: 'master', assignee_id: 42}"

Web version is available at https://gitlab-live.herokuapp.com
For more information, refer to website.

Development With a dockerized GitLab instance
docker-compose up -d gitlab # Will start the GitLab instance in the background (approx. 3 minutes)

After a while, your GitLab instance will be accessible on http://localhost:3000.

Once you have set your new root password, you can login with the root user.

You can now setup a personal access token here: http://localhost:3000/profile/personal_access_tokens

Once you have your token, set the variables to the correct values in the docker.env file.

Then, launch the tool:

docker-compose run app
Gitlab.users
=> [

To launch the specs:

docker-compose run app rake spec
Want to use GitLab Enterprise?

Just change the image from gitlab/gitlab-ce:latest to gitlab/gitlab-ee:latest in the docker-compose.yml file.

With an external GitLab instance

First, set the variables to the correct values in the docker.env file.

Then, launch the tool:

docker-compose run app
Gitlab.users
=> [

To launch the specs,

docker-compose run app rake spec
Without Docker

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

For more information see CONTRIBUTING.md.

License

Released under the BSD 2-clause license. See LICENSE.txt for details.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4