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:



44
45
46
47
# File 'lib/gitlab/client/environments.rb', line 44

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:



73
74
75
# File 'lib/gitlab/client/environments.rb', line 73

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:



61
62
63
# File 'lib/gitlab/client/environments.rb', line 61

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:



30
31
32
# File 'lib/gitlab/client/environments.rb', line 30

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:



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

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:



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

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