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

Options Hash (options):

  • :scope (String)

    The scope of runners to show, one of: specific, shared, active, paused, online; showing all runners if none provided

See Also:



31
32
33
# File 'lib/gitlab/client/runners.rb', line 31

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')


156
157
158
159
# File 'lib/gitlab/client/runners.rb', line 156

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

#delete_runner(id) ⇒ Gitlab::ObjectifiedHash

Remove a runner.

Examples:

Gitlab.delete_runner(42)

See Also:



72
73
74
# File 'lib/gitlab/client/runners.rb', line 72

def delete_runner(id)
  delete("/runners/#{id}")
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)

See Also:



124
125
126
# File 'lib/gitlab/client/runners.rb', line 124

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)

See Also:



110
111
112
113
# File 'lib/gitlab/client/runners.rb', line 110

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) ⇒ 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)

See Also:



97
98
99
# File 'lib/gitlab/client/runners.rb', line 97

def project_runners(project_id)
  get("/projects/#{url_encode project_id}/runners")
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)

Options Hash (options):

  • :description (String)

    Runner description.

  • :info (Hash)

    Runner metadata.

  • :active (Boolean)

    Whether the Runner is active.

  • :locked (Boolean)

    Whether the Runner should be locked for current project.

  • :run_untagged (Boolean)

    Whether the Runner should handle untagged jobs.

  • :tag_list (Array<String>)

    List of Runner tags.

  • :maximum_timeout (Integer)

    Maximum timeout set when this Runner will handle the job.



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

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

#runner(id) ⇒ Gitlab::ObjectifiedHash

Get details of a runner..



43
44
45
# File 'lib/gitlab/client/runners.rb', line 43

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

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

Gets a list of Jobs for a Runner

Examples:

Gitlab.runner_jobs(1)

Options Hash (options):

  • :status (String)

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



85
86
87
# File 'lib/gitlab/client/runners.rb', line 85

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(:active)
Gitlab.runners(:paused)

Options Hash (options):

  • :scope (String)

    The scope of specific runners to show, one of: active, paused, online; showing all runners if none provided

See Also:



18
19
20
# File 'lib/gitlab/client/runners.rb', line 18

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 })
Gitlab.update_runner(42, { tag_list: [ 'awesome', 'runner' ] })

Options Hash (options):

  • :active (String)

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

  • :tag_list (String)

    The list of tags for a runner; put array of tags, that should be finally assigned to a runner

See Also:



60
61
62
# File 'lib/gitlab/client/runners.rb', line 60

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

#verify_auth_registered_runner(token) ⇒ nil

Validates authentication credentials for a registered Runner.

Examples:

Gitlab.verify_auth_registered_runner('9142c16ea169eaaea3d752313a434a6e')


168
169
170
171
# File 'lib/gitlab/client/runners.rb', line 168

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