Module: DroneCI::BuildsAPI
- Included in:
- API
- Defined in:
- lib/drone-ci/api/builds.rb
Instance Method Summary collapse
-
#build_approve(owner, repo, build) ⇒ Object
Approves a blocked build.
-
#build_create(namespace, name, branch: nil, commit: nil, **params) ⇒ Object
Create a build using the latest commit for the specified branch.
-
#build_decline(owner, repo, build) ⇒ Object
Declines a blocked build.
-
#build_info(owner, repo, build) ⇒ Object
Returns the specified repository build.
-
#build_list(owner, repo, branch: nil, tag: nil, page: 1, per_page: 25) ⇒ Object
Returns recent builds for the repository based on name.
-
#build_logs(owner, repo, build, stage, step) ⇒ Object
Please note this api requires read access to the repository.
-
#build_promote(owner, repo, build, target:) ⇒ Object
Promote the specified build number to the target environment.
-
#build_start(owner, repo, build) ⇒ Object
(also: #build_restart)
Restart the specified build.
-
#build_stop(owner, repo, build) ⇒ Object
Stop the specified build.
Instance Method Details
#build_approve(owner, repo, build) ⇒ Object
Approves a blocked build.
Please note this api requires write access to the repository, and the request parameter build is not the build id but the build number.
Reference: docs.drone.io/api/builds/build_approve/
10 11 12 |
# File 'lib/drone-ci/api/builds.rb', line 10 def build_approve(owner, repo, build) api.post("repos/#{owner}/#{repo}/builds/#{build}/approve") end |
#build_create(namespace, name, branch: nil, commit: nil, **params) ⇒ Object
Create a build using the latest commit for the specified branch.
Please note the resulting build is created with event type ‘custom`.
Reference: docs.drone.io/api/builds/build_create/
19 20 21 22 23 24 25 |
# File 'lib/drone-ci/api/builds.rb', line 19 def build_create(namespace, name, branch: nil, commit: nil, **params) api.post("repos/#{namespace}/#{name}/builds") do |request| { branch: branch, commit: commit }.merge(params).compact.transform_keys(&:to_s).each do |key, value| request.params[key] = value end end end |
#build_decline(owner, repo, build) ⇒ Object
Declines a blocked build.
Please note this api requires write access to the repository, and the request parameter build is not the build id but the build number.
Reference: docs.drone.io/api/builds/build_decline/
32 33 34 |
# File 'lib/drone-ci/api/builds.rb', line 32 def build_decline(owner, repo, build) api.post("repos/#{owner}/#{repo}/builds/#{build}/decline") end |
#build_info(owner, repo, build) ⇒ Object
Returns the specified repository build.
Please note this api requires read access to the repository and the request parameter build is not the build id but the build number.
Reference: docs.drone.io/api/builds/build_info/
41 42 43 |
# File 'lib/drone-ci/api/builds.rb', line 41 def build_info(owner, repo, build) api.get("repos/#{owner}/#{repo}/builds/#{build}") end |
#build_list(owner, repo, branch: nil, tag: nil, page: 1, per_page: 25) ⇒ Object
Returns recent builds for the repository based on name.
Please note this api requires read access to the repository.
Reference: docs.drone.io/api/builds/build_list/
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/drone-ci/api/builds.rb', line 50 def build_list(owner, repo, branch: nil, tag: nil, page: 1, per_page: 25) api.get("repos/#{owner}/#{repo}/builds") do |request| { branch: branch, commit: commit, page: page, per_page: [[per_page, 1].max, 100].min, # https://github.com/harness/drone/blob/cbfd342333ffa4b2fe76b7e8948235efd3535fac/handler/api/repos/builds/list.go#L45-L47 }.compact.transform_keys(&:to_s).each do |key, value| request.params[key] = value end end end |
#build_logs(owner, repo, build, stage, step) ⇒ Object
Please note this api requires read access to the repository.
Reference: docs.drone.io/api/builds/build_logs/
66 67 68 |
# File 'lib/drone-ci/api/builds.rb', line 66 def build_logs(owner, repo, build, stage, step) api.get("repos/#{owner}/#{repo}/builds/#{build}/logs/#{stage}/#{step}") end |
#build_promote(owner, repo, build, target:) ⇒ Object
Promote the specified build number to the target environment.
If given, additional (custom) parameters will be available to your pipeline steps as environment variables.
Please note this api requires write access to the repository.
Reference: docs.drone.io/api/builds/build_promote/
77 78 79 80 81 82 83 |
# File 'lib/drone-ci/api/builds.rb', line 77 def build_promote(owner, repo, build, target:) api.post("repos/#{owner}/#{repo}/builds/#{build}") do |request| { target: target }.compact.transform_keys(&:to_s).each do |key, value| request.params[key] = value end end end |
#build_start(owner, repo, build) ⇒ Object Also known as: build_restart
Restart the specified build.
Please note this api requires read and write access to the repository and the request parameter build is not the build id but the build number.
Reference: docs.drone.io/api/builds/build_start/
90 91 92 |
# File 'lib/drone-ci/api/builds.rb', line 90 def build_start(owner, repo, build) api.post("repos/#{owner}/#{repo}/builds/#{build}") end |
#build_stop(owner, repo, build) ⇒ Object
Stop the specified build.
Please note this api requires administrative privileges and the request parameter build is not the build id but the build number.
Reference: docs.drone.io/api/builds/build_stop/
101 102 103 |
# File 'lib/drone-ci/api/builds.rb', line 101 def build_stop(owner, repo, build) api.delete("repos/#{owner}/#{repo}/builds/#{build}") end |