diff options
Diffstat (limited to 'qa/qa/resource/pipeline.rb')
-rw-r--r-- | qa/qa/resource/pipeline.rb | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/qa/qa/resource/pipeline.rb b/qa/qa/resource/pipeline.rb index 907a6cb8558..910065d76a8 100644 --- a/qa/qa/resource/pipeline.rb +++ b/qa/qa/resource/pipeline.rb @@ -9,10 +9,10 @@ module QA end end - attribute :id - attribute :status - attribute :ref - attribute :sha + attributes :id, + :status, + :ref, + :sha # array in form # [ @@ -33,6 +33,14 @@ module QA Page::Project::Pipeline::New.perform(&:click_run_pipeline_button) end + def fabricate_via_api! + resource_web_url(api_get) + rescue ResourceNotFoundError + super + rescue NoValueError + super + end + def ref project.default_branch end @@ -51,6 +59,40 @@ module QA variables: variables } end + + def pipeline_variables + response = get(request_url("#{api_get_path}/variables")) + + unless response.code == HTTP_STATUS_OK + raise ResourceQueryError, "Could not get variables. Request returned (#{response.code}): `#{response}`." + end + + parse_body(response) + end + + def has_variable?(key:, value:) + pipeline_variables.any? { |var| var[:key] == key && var[:value] == value } + end + + def has_no_variable?(key:, value:) + !pipeline_variables.any? { |var| var[:key] == key && var[:value] == value } + end + + def pipeline_bridges + response = get(request_url("#{api_get_path}/bridges")) + + unless response.code == HTTP_STATUS_OK + raise ResourceQueryError, "Could not get bridges. Request returned (#{response.code}): `#{response}`." + end + + parse_body(response) + end + + def downstream_pipeline_id(bridge_name:) + result = pipeline_bridges.find { |bridge| bridge[:name] == bridge_name } + + result[:downstream_pipeline][:id] + end end end end |