Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1e58dd09
Commit
1e58dd09
authored
Aug 11, 2021
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer CI_API_V4_URL for scripts/api/cancel_pipeline.rb
Also avoid using global GitLab client
parent
34836d37
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
scripts/api/cancel_pipeline.rb
scripts/api/cancel_pipeline.rb
+6
-6
scripts/api/get_job_id.rb
scripts/api/get_job_id.rb
+10
-10
No files found.
scripts/api/cancel_pipeline.rb
View file @
1e58dd09
...
...
@@ -18,19 +18,19 @@ class CancelPipeline
@project
=
options
.
delete
(
:project
)
@pipeline_id
=
options
.
delete
(
:pipeline_id
)
Gitlab
.
configure
do
|
config
|
config
.
endpoint
=
'https://gitlab.com/api/v4'
config
.
private_token
=
options
.
delete
(
:api_token
)
end
@client
=
Gitlab
.
client
(
endpoint:
ENV
.
fetch
(
'CI_API_V4_URL'
,
'https://gitlab.com/api/v4'
),
private_token:
options
.
delete
(
:api_token
)
)
end
def
execute
Gitlab
.
cancel_pipeline
(
project
,
pipeline_id
)
client
.
cancel_pipeline
(
project
,
pipeline_id
)
end
private
attr_reader
:project
,
:pipeline_id
attr_reader
:project
,
:pipeline_id
,
:client
end
if
$0
==
__FILE__
...
...
scripts/api/get_job_id.rb
View file @
1e58dd09
...
...
@@ -28,10 +28,10 @@ class JobFinder
warn
"No API token given."
if
api_token
.
empty?
Gitlab
.
configure
do
|
config
|
config
.
endpoint
=
'https://gitlab.com/api/v4'
config
.
private_token
=
api_token
end
@client
=
Gitlab
.
client
(
endpoint:
'https://gitlab.com/api/v4'
,
private_token:
api_token
)
end
def
execute
...
...
@@ -40,13 +40,13 @@ class JobFinder
private
attr_reader
:project
,
:pipeline_query
,
:job_query
,
:pipeline_id
,
:job_name
,
:artifact_path
attr_reader
:project
,
:pipeline_query
,
:job_query
,
:pipeline_id
,
:job_name
,
:artifact_path
,
:client
def
find_job_with_artifact
return
if
artifact_path
.
nil?
Gitlab
.
pipelines
(
project
,
pipeline_query_params
).
auto_paginate
do
|
pipeline
|
Gitlab
.
pipeline_jobs
(
project
,
pipeline
.
id
,
job_query_params
).
auto_paginate
do
|
job
|
client
.
pipelines
(
project
,
pipeline_query_params
).
auto_paginate
do
|
pipeline
|
client
.
pipeline_jobs
(
project
,
pipeline
.
id
,
job_query_params
).
auto_paginate
do
|
job
|
return
job
if
found_job_with_artifact?
(
job
)
# rubocop:disable Cop/AvoidReturnFromBlocks
end
end
...
...
@@ -57,8 +57,8 @@ class JobFinder
def
find_job_with_filtered_pipelines
return
if
pipeline_query
.
empty?
Gitlab
.
pipelines
(
project
,
pipeline_query_params
).
auto_paginate
do
|
pipeline
|
Gitlab
.
pipeline_jobs
(
project
,
pipeline
.
id
,
job_query_params
).
auto_paginate
do
|
job
|
client
.
pipelines
(
project
,
pipeline_query_params
).
auto_paginate
do
|
pipeline
|
client
.
pipeline_jobs
(
project
,
pipeline
.
id
,
job_query_params
).
auto_paginate
do
|
job
|
return
job
if
found_job_by_name?
(
job
)
# rubocop:disable Cop/AvoidReturnFromBlocks
end
end
...
...
@@ -69,7 +69,7 @@ class JobFinder
def
find_job_in_pipeline
return
unless
pipeline_id
Gitlab
.
pipeline_jobs
(
project
,
pipeline_id
,
job_query_params
).
auto_paginate
do
|
job
|
client
.
pipeline_jobs
(
project
,
pipeline_id
,
job_query_params
).
auto_paginate
do
|
job
|
return
job
if
found_job_by_name?
(
job
)
# rubocop:disable Cop/AvoidReturnFromBlocks
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment