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)


29
30
31
# File 'lib/gitlab/client/builds.rb', line 29

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)


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

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)


78
79
80
# File 'lib/gitlab/client/builds.rb', line 78

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)


102
103
104
# File 'lib/gitlab/client/builds.rb', line 102

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)


90
91
92
# File 'lib/gitlab/client/builds.rb', line 90

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 })

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.



17
18
19
# File 'lib/gitlab/client/builds.rb', line 17

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 })

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.



66
67
68
# File 'lib/gitlab/client/builds.rb', line 66

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