Commit 53fccf8d authored by ddavison's avatar ddavison

Add Pipeline resource

Add pipelines method to project resource
parent 504fc45d
...@@ -72,6 +72,7 @@ module QA ...@@ -72,6 +72,7 @@ module QA
autoload :DeployKey, 'qa/resource/deploy_key' autoload :DeployKey, 'qa/resource/deploy_key'
autoload :DeployToken, 'qa/resource/deploy_token' autoload :DeployToken, 'qa/resource/deploy_token'
autoload :ProtectedBranch, 'qa/resource/protected_branch' autoload :ProtectedBranch, 'qa/resource/protected_branch'
autoload :Pipeline, 'qa/resource/pipeline'
autoload :CiVariable, 'qa/resource/ci_variable' autoload :CiVariable, 'qa/resource/ci_variable'
autoload :Runner, 'qa/resource/runner' autoload :Runner, 'qa/resource/runner'
autoload :PersonalAccessToken, 'qa/resource/personal_access_token' autoload :PersonalAccessToken, 'qa/resource/personal_access_token'
......
# frozen_string_literal: true
module QA
module Resource
class Pipeline < Base
attribute :project do
Resource::Project.fabricate! do |project|
project.name = 'project-with-pipeline'
end
end
attribute :id
attribute :status
attribute :ref
attribute :sha
# array in form
# [
# { key: 'UPLOAD_TO_S3', variable_type: 'file', value: true },
# { key: 'SOMETHING', variable_type: 'env_var', value: 'yes' }
# ]
attribute :variables
def initialize
@ref = 'master'
@variables = []
end
def fabricate!
project.visit!
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform(&:click_run_pipeline_button)
Page::Project::Pipeline::New.perform(&:click_run_pipeline_button)
end
def api_get_path
"/projects/#{project.id}/pipelines/#{id}"
end
def api_post_path
"/projects/#{project.id}/pipeline"
end
def api_post_body
{
ref: ref,
variables: variables
}
end
end
end
end
...@@ -100,6 +100,10 @@ module QA ...@@ -100,6 +100,10 @@ module QA
"#{api_get_path}/runners" "#{api_get_path}/runners"
end end
def api_pipelines_path
"#{api_get_path}/pipelines"
end
def api_put_path def api_put_path
"/projects/#{id}" "/projects/#{id}"
end end
...@@ -161,6 +165,10 @@ module QA ...@@ -161,6 +165,10 @@ module QA
parse_body(response) parse_body(response)
end end
def pipelines
parse_body(get(Runtime::API::Request.new(api_client, api_pipelines_path).url))
end
def share_with_group(invitee, access_level = Resource::Members::AccessLevel::DEVELOPER) def share_with_group(invitee, access_level = Resource::Members::AccessLevel::DEVELOPER)
post Runtime::API::Request.new(api_client, "/projects/#{id}/share").url, { group_id: invitee.id, group_access: access_level } post Runtime::API::Request.new(api_client, "/projects/#{id}/share").url, { group_id: invitee.id, group_access: access_level }
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment