diff options
Diffstat (limited to 'app/models/ci/build.rb')
-rw-r--r-- | app/models/ci/build.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 65dfe4f0190..20492c54729 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -18,6 +18,7 @@ module Ci scope :latest_successful_with_artifacts, ->() do with_artifacts.success.order(id: :desc) end + scope :manual_actions, ->() { where(when: :manual) } mount_uploader :artifacts_file, ArtifactUploader mount_uploader :artifacts_metadata, ArtifactUploader @@ -94,6 +95,29 @@ module Ci end end + def manual? + self.when == 'manual' + end + + def other_actions + pipeline.manual_actions.where.not(id: self) + end + + def playable? + project.builds_enabled? && commands.present? && manual? + end + + def play(current_user = nil) + # Try to queue a current build + if self.queue + self.update(user: current_user) + self + else + # Otherwise we need to create a duplicate + Ci::Build.retry(self, current_user) + end + end + def retryable? project.builds_enabled? && commands.present? && complete? end |