Module: Gitlab::Client::PipelineTriggers

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

Overview

Defines methods related to pipelines.

Instance Method Summary collapse

Instance Method Details

#create_trigger(project, description) ⇒ Gitlab::ObjectifiedHash

Create a pipeline trigger for a project.

Examples:

Gitlab.create_trigger(5, description: "my description")

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • description (String)

    The trigger name

Returns:



39
40
41
# File 'lib/gitlab/client/pipeline_triggers.rb', line 39

def create_trigger(project, description)
  post("/projects/#{url_encode project}/triggers", body: { description: description })
end

#remove_trigger(project, trigger_id) ⇒ void Also known as: delete_trigger

This method returns an undefined value.

Remove a project’s pipeline trigger.

Examples:

Gitlab.remove_trigger(5, 1)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • trigger_id (Integer)

    The trigger ID.



77
78
79
# File 'lib/gitlab/client/pipeline_triggers.rb', line 77

def remove_trigger(project, trigger_id)
  delete("/projects/#{url_encode project}/triggers/#{trigger_id}")
end

#run_trigger(project, token, ref, variables = {}) ⇒ Gitlab::ObjectifiedHash

Run the given project pipeline trigger.

Examples:

Gitlab.run_trigger(5, '7b9148c158980bbd9bcea92c17522d', 'master')
Gitlab.run_trigger(5, '7b9148c158980bbd9bcea92c17522d', 'master', { variable1: "value", variable2: "value2" })

Parameters:

  • project (Integer, String)

    The ID or name of the project.

  • token (String)

    The token of a trigger.

  • ref (String)

    Branch or tag name to build.

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

    A set of build variables to use for the build. (optional)

Returns:

See Also:



95
96
97
98
99
100
101
# File 'lib/gitlab/client/pipeline_triggers.rb', line 95

def run_trigger(project, token, ref, variables = {})
  post("/projects/#{url_encode project}/trigger/pipeline", unauthenticated: true, body: {
         token: token,
         ref: ref,
         variables: variables
       })
end

#trigger(project, trigger_id) ⇒ Gitlab::ObjectifiedHash

Gets details of project’s pipeline trigger.

Examples:

Gitlab.trigger(5, 1)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • trigger_id (Integer)

    The trigger ID.

Returns:



27
28
29
# File 'lib/gitlab/client/pipeline_triggers.rb', line 27

def trigger(project, trigger_id)
  get("/projects/#{url_encode project}/triggers/#{trigger_id}")
end

#trigger_take_ownership(project, trigger_id) ⇒ Gitlab::ObjectifiedHash

Take ownership of a project trigger

Examples:

Gitlab.trigger_take_ownership(5, 1)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • trigger_id (Integer)

    The trigger ID.

Returns:



65
66
67
# File 'lib/gitlab/client/pipeline_triggers.rb', line 65

def trigger_take_ownership(project, trigger_id)
  post("/projects/#{url_encode project}/triggers/#{trigger_id}/take_ownership")
end

#triggers(project) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of the project’s pipeline triggers

Examples:

Gitlab.triggers(5)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

Returns:



15
16
17
# File 'lib/gitlab/client/pipeline_triggers.rb', line 15

def triggers(project)
  get("/projects/#{url_encode project}/triggers")
end

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

Update a project trigger

Examples:

Gitlab.update_trigger(5, 1, description: "my description")

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • trigger_id (Integer)

    The trigger ID.

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

    A customizable set of options.

Options Hash (options):

  • :description (String)

    The trigger name.

Returns:



53
54
55
# File 'lib/gitlab/client/pipeline_triggers.rb', line 53

def update_trigger(project, trigger_id, options = {})
  put("/projects/#{url_encode project}/triggers/#{trigger_id}", body: options)
end