Skip to content

Commit

Permalink
Merge pull request #678 from capripot/pipeline-variables
Browse files Browse the repository at this point in the history
Pipeline variables
  • Loading branch information
NARKOZ authored Jun 13, 2024
2 parents 131d513 + 7311bc4 commit 35dcb04
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
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

0 comments on commit 35dcb04

Please sign in to comment.