Module: Gitlab::Client::Builds

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

Overview

Defines methods related to builds.

Instance Method Summary collapse

Instance Method Details

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

Gets a single build.

Examples:

Gitlab.build(5, 36)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a build.

Returns:


31
32
33
# File 'lib/gitlab/client/builds.rb', line 31

def build(project, id)
  get("/projects/#{url_encode project}/builds/#{id}")
end

#build_artifacts(project, id) ⇒ Gitlab::FileResponse

Gets build artifacts.

Examples:

Gitlab.build_artifacts(1, 8)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a build.

Returns:


43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/gitlab/client/builds.rb', line 43

def build_artifacts(project, id)
  get("/projects/#{url_encode project}/builds/#{id}/artifacts",
      format: nil,
      headers: { Accept: 'application/octet-stream' },
      parser: proc { |body, _|
                if body.encoding == Encoding::ASCII_8BIT # binary response
                  ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
                else # error with json response
                  ::Gitlab::Request.parse(body)
                end
              })
end

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

Cancels a build.

Examples:

Gitlab.build_cancel(5, 1)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a build.

Returns:


80
81
82
# File 'lib/gitlab/client/builds.rb', line 80

def build_cancel(project, id)
  post("/projects/#{url_encode project}/builds/#{id}/cancel")
end

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

Erase a single build of a project (remove build artifacts and a build trace)

Examples:

Gitlab.build_erase(5, 1)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a build.

Returns:


104
105
106
# File 'lib/gitlab/client/builds.rb', line 104

def build_erase(project, id)
  post("/projects/#{url_encode project}/builds/#{id}/erase")
end

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

Retry a build.

Examples:

Gitlab.build_retry(5, 1)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a build.

Returns:


92
93
94
# File 'lib/gitlab/client/builds.rb', line 92

def build_retry(project, id)
  post("/projects/#{url_encode project}/builds/#{id}/retry")
end

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

Gets a list of project builds.

Examples:

Gitlab.builds(5)
Gitlab.builds(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.

  • project (Integer, String)

    The ID or name of a project.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:


19
20
21
# File 'lib/gitlab/client/builds.rb', line 19

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

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

Gets a list of builds for specific commit in a project.

Examples:

Gitlab.commit_builds(5, 'asdf')
Gitlab.commit_builds(5, 'asdf', { per_page: 10, page: 2 })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • sha (String)

    The SHA checksum of a commit.

  • 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:


68
69
70
# File 'lib/gitlab/client/builds.rb', line 68

def commit_builds(project, sha, options = {})
  get("/projects/#{url_encode project}/repository/commits/#{sha}/builds", query: options)
end