Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/gitlab/client/pipelines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ def pipeline_test_report(project, id)
get("/projects/#{url_encode project}/pipelines/#{id}/test_report")
end

# Gets a single pipeline's variables.
#
# @example
# Gitlab.pipeline_variables(5, 36)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] id The ID of a pipeline.
# @return [Array<Gitlab::ObjectifiedHash>]
def pipeline_variables(project, id)
get("/projects/#{url_encode project}/pipelines/#{id}/variables")
end

# Create a pipeline.
#
# @example
Expand Down
11 changes: 11 additions & 0 deletions spec/fixtures/pipeline_variables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"key": "RUN_NIGHTLY_BUILD",
"variable_type": "env_var",
"value": "true"
},
{
"key": "foo",
"value": "bar"
}
]
19 changes: 19 additions & 0 deletions spec/gitlab/client/pipelines_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@
end
end

describe '.pipeline_variables' do
before do
stub_get('/projects/3/pipelines/46/variables', 'pipeline_variables')
@variables = Gitlab.pipeline_variables(3, 46)
end

it 'gets the correct resource' do
expect(a_get('/projects/3/pipelines/46/variables')).to have_been_made
end

it 'returns a paginated response of pipeline variables' do
expect(@variables).to be_a Gitlab::PaginatedResponse
end

it "returns pipeline's variables" do
expect(@variables[0]['key']).to eq('RUN_NIGHTLY_BUILD')
end
end

describe '.create_pipeline' do
let(:pipeline_path) { '/projects/3/pipeline?ref=master' }

Expand Down