Module: Gitlab::Client::Runners

Included in:
Gitlab::Client
Defined in:
lib/gitlab/client/runners.rb

Overview

Defines methods related to runners.

Instance Method Summary collapse

Instance Method Details

#all_runners(options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.

Examples:

Gitlab.all_runners
Gitlab.all_runners(type: 'instance_type', status: 'active')
Gitlab.all_runners(tag_list: 'tag1,tag2')

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :type(optional) (String)

    The type of runners to show, one of: instance_type, group_type, project_type

  • :status(optional) (String)

    The status of runners to show, one of: active, paused, online, offline

  • :tag_list(optional) (String)

    List of the runners tags (separated by comma)

Returns:

See Also:



37
38
39
# File 'lib/gitlab/client/runners.rb', line 37

def all_runners(options = {})
  get('/runners/all', query: options)
end

#delete_registered_runner(token) ⇒ nil

Deletes a registed Runner.

Examples:

Gitlab.delete_registered_runner('9142c16ea169eaaea3d752313a434a6e')

Parameters:

  • token (String)

    Runner authentication token.

Returns:

  • (nil)

    This API call returns an empty response body.



194
195
196
197
# File 'lib/gitlab/client/runners.rb', line 194

def delete_registered_runner(token)
  body = { token: token }
  delete('/runners', body: body)
end

#delete_runner(id) ⇒ nil

Remove a runner.

Examples:

Gitlab.delete_runner(42)

Parameters:

  • id (Integer, String)

    The ID of a runner

Returns:

  • (nil)

    This API call returns an empty response body.

See Also:



82
83
84
# File 'lib/gitlab/client/runners.rb', line 82

def delete_runner(id)
  delete("/runners/#{id}")
end

#group_runners(group, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

List all runners (specific and shared) available in the group as well its ancestor groups. Shared runners are listed if at least one shared runner is defined.

Examples:

Gitlab.group_runners(9)
Gitlab.group_runners(9, type: 'instance_type', status: 'active')
Gitlab.group_runners(9, tag_list: 'tag1,tag2')

Parameters:

  • id (Integer, String)

    The ID or name of a project.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :type(optional) (String)

    The type of runners to show, one of: instance_type, group_type, project_type

  • :status(optional) (String)

    The status of runners to show, one of: active, paused, online, offline

  • :tag_list(optional) (String)

    List of the runners tags (separated by comma)

Returns:

See Also:



162
163
164
# File 'lib/gitlab/client/runners.rb', line 162

def group_runners(group, options = {})
  get("/groups/#{url_encode group}/runners", query: options)
end

#project_disable_runner(id, runner_id) ⇒ Gitlab::ObjectifiedHash

Disable a specific runner from the project. It works only if the project isn’t the only project associated with the specified runner.

Examples:

Gitlab.project_disable_runner(2, 42)

Parameters:

  • id (Integer, String)

    The ID or name of a project.

  • runner_id (Integer, String)

    The ID of a runner.

Returns:

See Also:



144
145
146
# File 'lib/gitlab/client/runners.rb', line 144

def project_disable_runner(id, runner_id)
  delete("/projects/#{url_encode id}/runners/#{runner_id}")
end

#project_enable_runner(project_id, id) ⇒ Gitlab::ObjectifiedHash

Enable an available specific runner in the project.

Examples:

Gitlab.project_enable_runner(2, 42)

Parameters:

  • id (Integer, String)

    The ID or name of a project.

  • id (Integer, String)

    The ID of a runner.

Returns:

See Also:



130
131
132
133
# File 'lib/gitlab/client/runners.rb', line 130

def project_enable_runner(project_id, id)
  body = { runner_id: id }
  post("/projects/#{url_encode project_id}/runners", body: body)
end

#project_runners(project_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

List all runners (specific and shared) available in the project. Shared runners are listed if at least one shared runner is defined and shared runners usage is enabled in the project’s settings.

Examples:

Gitlab.project_runners(42)
Gitlab.project_runners(42, type: 'instance_type', status: 'active')
Gitlab.project_runners(42, tag_list: 'tag1,tag2')

Parameters:

  • id (Integer, String)

    The ID or name of a project.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :type(optional) (String)

    The type of runners to show, one of: instance_type, group_type, project_type

  • :status(optional) (String)

    The status of runners to show, one of: active, paused, online, offline

  • :tag_list(optional) (String)

    List of the runners tags (separated by comma)

Returns:

See Also:



117
118
119
# File 'lib/gitlab/client/runners.rb', line 117

def project_runners(project_id, options = {})
  get("/projects/#{url_encode project_id}/runners", query: options)
end

#register_runner(token, options = {}) ⇒ Gitlab::ObjectifiedHash

Register a new Runner for the instance.

Examples:

Gitlab.register_runner('9142c16ea169eaaea3d752313a434a6e')
Gitlab.register_runner('9142c16ea169eaaea3d752313a434a6e', description: 'Some Description', active: true, locked: false)

Parameters:

  • token(required) (String)

    Registration token.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :description(optional) (String)

    Runner description.

  • :info(optional) (Hash)

    Runner metadata.

  • :active(optional) (Boolean)

    Whether the Runner is active.

  • :locked(optional) (Boolean)

    Whether the Runner should be locked for current project.

  • :run_untagged(optional) (Boolean)

    Whether the Runner should handle untagged jobs.

  • :tag_list(optional) (Array<String>)

    List of Runner tags.

  • :maximum_timeout(optional) (Integer)

    Maximum timeout set when this Runner will handle the job.

Returns:



182
183
184
185
# File 'lib/gitlab/client/runners.rb', line 182

def register_runner(token, options = {})
  body = { token: token }.merge(options)
  post('/runners', body: body)
end

#runner(id) ⇒ Gitlab::ObjectifiedHash

Get details of a runner..

Examples:

Gitlab.runner(42)

Parameters:

  • id (Integer, String)

    The ID of a runner

Returns:

See Also:



49
50
51
# File 'lib/gitlab/client/runners.rb', line 49

def runner(id)
  get("/runners/#{id}")
end

#runner_jobs(runner_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

List jobs that are being processed or were processed by specified runner.

Examples:

Gitlab.runner_jobs(1)
Gitlab.runner_jobs(1, status: 'success')
Gitlab.runner_jobs(1, sort: 'desc')

Parameters:

  • id (Integer)

    The ID of a runner.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :status(optional) (String)

    Status of the job; one of: running, success, failed, canceled

  • :order_by(optional) (String)

    Order jobs by id.

  • :sort(optional) (String)

    Sort jobs in asc or desc order (default: desc)

Returns:



99
100
101
# File 'lib/gitlab/client/runners.rb', line 99

def runner_jobs(runner_id, options = {})
  get("/runners/#{url_encode runner_id}/jobs", query: options)
end

#runners(options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Get a list of specific runners available to the user.

Examples:

Gitlab.runners
Gitlab.runners(type: 'instance_type', status: 'active')
Gitlab.runners(tag_list: 'tag1,tag2')

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :type(optional) (String)

    The type of runners to show, one of: instance_type, group_type, project_type

  • :status(optional) (String)

    The status of runners to show, one of: active, paused, online, offline

  • :tag_list(optional) (String)

    List of the runners tags (separated by comma)

Returns:

See Also:



20
21
22
# File 'lib/gitlab/client/runners.rb', line 20

def runners(options = {})
  get('/runners', query: options)
end

#update_runner(id, options = {}) ⇒ Gitlab::ObjectifiedHash

Update details of a runner.

Examples:

Gitlab.update_runner(42, { description: 'Awesome runner' })
Gitlab.update_runner(42, { active: false })

Parameters:

  • id (Integer, String)

    The ID of a runner

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :description(optional) (String)

    The description of a runner

  • :active(optional) (Boolean)

    The state of a runner; can be set to true or false

  • :tag_list(optional) (String)

    The list of tags for a runner; put array of tags, that should be finally assigned to a runner(separated by comma)

  • :run_untagged(optional) (Boolean)

    Flag indicating the runner can execute untagged jobs

  • :locked(optional) (Boolean)

    Flag indicating the runner is locked

  • :access_level(optional) (String)

    The access_level of the runner; not_protected or ref_protected

  • :maximum_timeout(optional) (Integer)

    Maximum timeout set when this runner will handle the job

Returns:

See Also:



70
71
72
# File 'lib/gitlab/client/runners.rb', line 70

def update_runner(id, options = {})
  put("/runners/#{id}", body: options)
end

#verify_auth_registered_runner(token) ⇒ nil

Validates authentication credentials for a registered Runner.

Examples:

Gitlab.verify_auth_registered_runner('9142c16ea169eaaea3d752313a434a6e')

Parameters:

  • token (String)

    Runner authentication token.

Returns:

  • (nil)

    This API call returns an empty response body.



206
207
208
209
# File 'lib/gitlab/client/runners.rb', line 206

def verify_auth_registered_runner(token)
  body = { token: token }
  post('/runners/verify', body: body)
end