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

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)

See Also:



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

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

#create_group_runner(group, options = {}) ⇒ Gitlab::ObjectifiedHash

Creates a new group runner with the new Gitlab approach (v16.0+) and returns the id/token information docs.gitlab.com/ee/api/users.html#create-a-runner You must use an access token with the create_runner scope

Examples:

Gitlab.create_group_runner(9, tag_list: ['one', 'two'])
Gitlab.create_group_runner(9, paused: false, description: 'A note', run_untagged: true)


222
223
224
# File 'lib/gitlab/client/runners.rb', line 222

def create_group_runner(group, options = {})
  create_runner({ runner_type: 'group_type', group_id: group }.merge(options))
end

#create_instance_runner(options = {}) ⇒ Gitlab::ObjectifiedHash

Creates a new instance runner with the new Gitlab approach (v16.0+) and returns the id/token information You must be an administrator of the GitLab instance You must use an access token with the create_runner scope docs.gitlab.com/ee/api/users.html#create-a-runner

Examples:

Gitlab.create_instance_runner(tag_list: ['one', 'two'])
Gitlab.create_instance_runner(paused: false, description: 'A note', run_untagged: true)


253
254
255
# File 'lib/gitlab/client/runners.rb', line 253

def create_instance_runner(options = {})
  create_runner({ runner_type: 'instance_type' }.merge(options))
end

#create_project_runner(project, options = {}) ⇒ Gitlab::ObjectifiedHash

Creates a new project runner with the new Gitlab approach (v16.0+) and returns the id/token information docs.gitlab.com/ee/api/users.html#create-a-runner You must use an access token with the create_runner scope

Examples:

Gitlab.create_project_runner(12, tag_list: ['one', 'two'])
Gitlab.create_project_runner(12, paused: false, description: 'A note', run_untagged: true)


237
238
239
# File 'lib/gitlab/client/runners.rb', line 237

def create_project_runner(project, options = {})
  create_runner({ runner_type: 'project_type', project_id: project }.merge(options))
end

#delete_registered_runner(token) ⇒ nil

Deletes a registed Runner.

Examples:

Gitlab.delete_registered_runner('9142c16ea169eaaea3d752313a434a6e')


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)

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

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)

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)

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)

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

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)

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)

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.



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..



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

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)



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

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)

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

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

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


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