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
a9e566d0
Commit
a9e566d0
authored
Dec 01, 2020
by
Rémy Coutable
Committed by
Lin Jen-Shin
Dec 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tooling: Work around a gitlab gem bug to make unauthenticated requests
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
72fdd799
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
21 deletions
+10
-21
scripts/api/get_job_id
scripts/api/get_job_id
+10
-21
No files found.
scripts/api/get_job_id
View file @
a9e566d0
...
...
@@ -4,7 +4,6 @@
require
'rubygems'
require
'gitlab'
require
'optparse'
require
'cgi'
class
JobFinder
DEFAULT_OPTIONS
=
{
...
...
@@ -21,14 +20,16 @@ class JobFinder
@job_query
=
options
.
delete
(
:job_query
)
@pipeline_id
=
options
.
delete
(
:pipeline_id
)
@job_name
=
options
.
delete
(
:job_name
)
@api_token
=
options
.
delete
(
:api_token
)
# Force the token to be a string so that if api_token is nil, it's set to '', allowing unauthenticated requests (for forks).
api_token
=
options
.
delete
(
:api_token
).
to_s
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
if
api_token
config
.
private_token
=
api_token
end
warn
"No API token given."
unless
api_token
end
def
execute
...
...
@@ -37,21 +38,13 @@ class JobFinder
private
attr_reader
:project
,
:pipeline_query
,
:job_query
,
:pipeline_id
,
:job_name
,
:api_token
attr_reader
:project
,
:pipeline_query
,
:job_query
,
:pipeline_id
,
:job_name
def
find_job_with_filtered_pipelines
return
if
pipeline_query
.
empty?
Gitlab
.
get
(
"/projects/
#{
CGI
.
escape
(
project
)
}
/pipelines"
,
query:
pipeline_query_params
,
unauthenticated:
api_token
.
nil?
).
auto_paginate
do
|
pipeline
|
Gitlab
.
get
(
"/projects/
#{
CGI
.
escape
(
project
)
}
/pipelines/
#{
pipeline
.
id
}
/jobs"
,
query:
job_query_params
,
unauthenticated:
api_token
.
nil?
).
auto_paginate
do
|
job
|
Gitlab
.
pipelines
(
project
,
pipeline_query_params
).
auto_paginate
do
|
pipeline
|
Gitlab
.
pipeline_jobs
(
project
,
pipeline
.
id
,
job_query_params
).
auto_paginate
do
|
job
|
return
job
if
job
.
name
==
job_name
# rubocop:disable Cop/AvoidReturnFromBlocks
end
end
...
...
@@ -62,11 +55,7 @@ class JobFinder
def
find_job_in_pipeline
return
unless
pipeline_id
Gitlab
.
get
(
"/projects/
#{
CGI
.
escape
(
project
)
}
/pipelines/
#{
pipeline_id
}
/jobs"
,
query:
job_query_params
,
unauthenticated:
api_token
.
nil?
).
auto_paginate
do
|
job
|
Gitlab
.
pipeline_jobs
(
project
,
pipeline_id
,
job_query_params
).
auto_paginate
do
|
job
|
return
job
if
job
.
name
==
job_name
# 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