File: configuration.md

package info (click to toggle)
ruby-gitlab 6.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,824 kB
  • sloc: ruby: 12,742; makefile: 7; sh: 4; javascript: 3
file content (55 lines) | stat: -rw-r--r-- 1,182 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!-- THIS DOCUMENT IS PUBLISHED ON https://narkoz.github.io/gitlab -->
# Configuration

You need to set an API endpoint URL before usage

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

Set the GitLab user's private token (not required for `session`)

```sh
Gitlab.private_token = 'qEsq1pt6HJPaNciie3MG'
```

## Sudo

Optionally, you can set the `sudo` parameter to perform API calls as another user

```sh
Gitlab.sudo = 'other_user'
```

To disable it:

```sh
Gitlab.sudo = nil
```

## Clients

You can set different configuration values for each client

```sh
client1 = Gitlab.client(endpoint: 'https://api1.example.com', private_token: 'user-001')
client2 = Gitlab.client(endpoint: 'https://api2.example.com', private_token: 'user-002')
```

## Environment variables

Gitlab uses `GITLAB_API_ENDPOINT` and `GITLAB_API_PRIVATE_TOKEN` environment
variables by default.

## Ruby on Rails

Create the file `config/initializers/gitlab.rb` and insert the following code
into it. Edit where necessary.

```rb
Gitlab.configure do |config|
  config.endpoint       = 'https://example.net/api/v4'
  config.private_token  = ''
  config.user_agent     = 'Custom User Agent'
end
```