Module: Gitlab::Client::BuildVariables

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

Overview

Defines methods related to builds.

Instance Method Summary collapse

Instance Method Details

#create_variable(project, key, value) ⇒ Gitlab::ObjectifiedHash

Create a build variable for a project.

Examples:

Gitlab.create_variable(5, "NEW_VARIABLE", "new value")

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • key (String)

    The key of a variable; must have no more than 255 characters; only `A-Z`, `a-z`, `0-9` and `_` are allowed

  • value (String)

    The value of a variable

Returns:



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

def create_variable(project, key, value)
  post("/projects/#{url_encode project}/variables", body: { key: key, value: value })
end

#remove_variable(project, key) ⇒ Gitlab::ObjectifiedHash

Remove a project's build variable.

Examples:

Gitlab.remove_variable(5, "VARIABLE_1")

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • key (String)

    The key of a variable.

Returns:



62
63
64
# File 'lib/gitlab/client/build_variables.rb', line 62

def remove_variable(project, key)
  delete("/projects/#{url_encode project}/variables/#{key}")
end

#update_variable(project, key, value) ⇒ Gitlab::ObjectifiedHash

Update a project's build variable.

Examples:

Gitlab.create_variable(5, "NEW_VARIABLE", "updated value")

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • key (String)

    The key of a variable

  • value (String)

    The value of a variable

Returns:



50
51
52
# File 'lib/gitlab/client/build_variables.rb', line 50

def update_variable(project, key, value)
  put("/projects/#{url_encode project}/variables/#{key}", body: { value: value })
end

#variable(project, key) ⇒ Gitlab::ObjectifiedHash

Gets details of a project's specific build variable.

Examples:

Gitlab.build(5, "TEST_VARIABLE_1")

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • key (String)

    The key of a variable.

Returns:



24
25
26
# File 'lib/gitlab/client/build_variables.rb', line 24

def variable(project, key)
  get("/projects/#{url_encode project}/variables/#{key}")
end

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

Gets a list of the project's build variables

Examples:

Gitlab.variables(5)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

Returns:



12
13
14
# File 'lib/gitlab/client/build_variables.rb', line 12

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