Module: Gitlab::Client::Environments

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

Overview

Defines methods related to environments.

Instance Method Summary collapse

Instance Method Details

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

Create an environment.

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • env_name (String)

    Name for the environment

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

    a customizable set of options

Options Hash (options):

  • :external_url (String)

    Optional URL for viewing the deployed project in this environment

Returns:



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

def create_environment(project, env_name, options = {})
  body = {name: env_name}.merge(options)
  post("/projects/#{url_encode project}/environments", body: body)
end

#delete_environment(project, id) ⇒ Gitlab::ObjectifiedHash

Deletes an environment.

Examples:

Gitlab.delete_environment(5, 36)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an environment.

Returns:



71
72
73
# File 'lib/gitlab/client/environments.rb', line 71

def delete_environment(project, id)
  delete("/projects/#{url_encode project}/environments/#{id}")
end

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

Update an environment.

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an environment.

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

    A hash of the attribute keys & values to update.

Options Hash (options):

  • env_name (String)

    Name for the environment

  • external_url (String)

    Optional URL for viewing the deployed project in this environment

Returns:



59
60
61
# File 'lib/gitlab/client/environments.rb', line 59

def edit_environment(project, id, options={})
  put("/projects/#{url_encode project}/environments/#{id}", body: options)
end

#environment(project, id) ⇒ Gitlab::ObjectifiedHash

Gets a single environment.

Examples:

Gitlab.environment(5, 36)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an environment.

Returns:



28
29
30
# File 'lib/gitlab/client/environments.rb', line 28

def environment(project, id)
  get("/projects/#{url_encode project}/environments/#{id}")
end

#environments(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of project environments.

Examples:

Gitlab.environments(5)
Gitlab.environments(5, { per_page: 10, page:  2 })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

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

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:



16
17
18
# File 'lib/gitlab/client/environments.rb', line 16

def environments(project, options={})
  get("/projects/#{url_encode project}/environments", query: options)
end

#stop_environment(project, id) ⇒ Array<Gitlab::ObjectifiedHash>

Stop an environment.

Examples:

Gitlab.stop_environment(5, 36)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of an environment.

Returns:



83
84
85
# File 'lib/gitlab/client/environments.rb', line 83

def stop_environment(project, id)
  post("/projects/#{url_encode project}/environments/#{id}/stop")
end