Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Roman Lacko
gitlab_api
Commits
6e67ef15
Commit
6e67ef15
authored
Feb 20, 2019
by
Roman Lacko
Committed by
Fakultni administrativa
Feb 20, 2019
Browse files
Add Jobs API
parent
853b6232
Changes
3
Show whitespace changes
Inline
Side-by-side
GitLab.pm
View file @
6e67ef15
...
@@ -11,6 +11,7 @@ use GitLab::Commits;
...
@@ -11,6 +11,7 @@ use GitLab::Commits;
use
GitLab::
CustomAttributes
;
use
GitLab::
CustomAttributes
;
use
GitLab::
Events
;
use
GitLab::
Events
;
use
GitLab::
Groups
;
use
GitLab::
Groups
;
use
GitLab::
Jobs
;
use
GitLab::
Members
;
use
GitLab::
Members
;
use
GitLab::
Namespaces
;
use
GitLab::
Namespaces
;
use
GitLab::
Projects
;
use
GitLab::
Projects
;
...
...
GitLab/API.pm
View file @
6e67ef15
...
@@ -86,7 +86,7 @@ sub new {
...
@@ -86,7 +86,7 @@ sub new {
$self
->
{
http
}
=
LWP::
UserAgent
->
new
(
$self
->
{
http
}
=
LWP::
UserAgent
->
new
(
default_headers
=>
HTTP::
Headers
->
new
(
default_headers
=>
HTTP::
Headers
->
new
(
"
P
RIVATE-TOKEN
"
=>
$self
->
{
token
},
"
P
rivate-Token
"
=>
$self
->
{
token
},
),
),
keep_alive
=>
$defaults
{
keep_alive
},
keep_alive
=>
$defaults
{
keep_alive
},
);
);
...
@@ -129,7 +129,7 @@ sub sudo {
...
@@ -129,7 +129,7 @@ sub sudo {
if
defined
$who
&&
!
$self
->
is_admin
;
if
defined
$who
&&
!
$self
->
is_admin
;
$log
->
debug
(
defined
$who
?
"
impersonating '
$who
'
"
:
"
stopped impersonation
");
$log
->
debug
(
defined
$who
?
"
impersonating '
$who
'
"
:
"
stopped impersonation
");
$self
->
http
->
default_header
(
S
UDO
=>
$who
);
$self
->
http
->
default_header
(
S
udo
=>
$who
);
$self
->
{
impersonate
}
=
$who
;
$self
->
{
impersonate
}
=
$who
;
return
;
# don't return default_header's output
return
;
# don't return default_header's output
...
...
GitLab/Jobs.pm
0 → 100644
View file @
6e67ef15
package
GitLab::
Jobs
;
use
utf8
;
use
strict
;
use
warnings
;
use
vars
qw($VERSION)
;
use
GitLab::
API
;
use
Log::
Any
qw($log)
;
our
$VERSION
=
v10
.4.1
;
my
$requests
=
{
project_jobs
=>
{
method
=>
"
GET
",
path
=>
"
/projects/<pid>/jobs
",
query
=>
[
qw(
scope
)
],
paginated
=>
1
,
},
pipeline_jobs
=>
{
method
=>
"
GET
",
path
=>
"
/projects/<pid>/pipelines/<pipeline_id>/jobs
",
query
=>
[
qw(
scope
)
],
paginated
=>
1
,
},
job
=>
{
method
=>
"
GET
",
path
=>
"
/projects/<pid>/jobs/<job_id>
",
},
# get_artifacts
# download_artifacts
# get_trace_file
job_cancel
=>
{
method
=>
"
POST
",
path
=>
"
/projects/<pid>/jobs/<job_id>/cancel
",
},
job_retry
=>
{
method
=>
"
POST
",
path
=>
"
/projects/<pid>/jobs/<job_id>/retry
",
},
job_erase
=>
{
method
=>
"
POST
",
path
=>
"
/projects/<pid>/jobs/<job_id>/erase
",
},
keep_artifacts
=>
{
method
=>
"
POST
",
path
=>
"
/projects/<pid>/jobs/<job_id>/artifacts/keep
",
},
job_play
=>
{
method
=>
"
POST
",
path
=>
"
/projects/<pid>/jobs/<job_id>/play
",
},
};
sub
import
{
$log
->
debug
("
initializing
"
.
__PACKAGE__
);
while
(
my
(
$name
,
$tmpl
)
=
each
(
%$requests
))
{
$tmpl
->
{
name
}
=
$name
unless
exists
$tmpl
->
{
name
};
GitLab::
API
->
register
(
$tmpl
);
}
}
1
;
__END__
=head1 NAME
GitLab::Jobs - implements jobs API calls
See L<GitLab API -- Jobs|https://docs.gitlab.com/ee/api/jobs.html> for details and
response formats.
=head1 VERSION
Implements API calls for GitLab CE C<v10.4.1>.
=head1 DESCRIPTION
=over
=item L<project_jobs()|https://docs.gitlab.com/ee/api/jobs.html#list-project-jobs>
$jobs = $gitlab->project_jobs( :pid[, :scope]);
Get a list of jobs in a project.
=item L<pipeline_jobs()|https://docs.gitlab.com/ee/api/jobs.html#list-pipeline-jobs>
$jobs = $gitlab->pipeline_jobs( :pid, :pipeline_id[, :scope]);
Get a list of jobs for a pipeline.
=item L<job()|https://docs.gitlab.com/ee/api/jobs.html#get-a-single-job>
$jobs = $gitlab->job( :pid, :job_id );
Get a single job of a project.
=item L<job_cancel()|https://docs.gitlab.com/ee/api/jobs.html#cancel-a-job>
$gitlab->job_cancel( :pid, :job_id );
Cancel a single job of a project.
=item L<job_retry()|https://docs.gitlab.com/ee/api/jobs.html#retry-a-job>
$gitlab->job_retry( :pid, :job_id );
Retry a single job of a project.
=item L<job_erase()|https://docs.gitlab.com/ee/api/jobs.html#erase-a-job>
$gitlab->job_erase( :pid, :job_id );
Erase a single job of a project (remove job artifacts and a job trace).
=item L<keep_artifacts()|https://docs.gitlab.com/ee/api/jobs.html#keep-artifacts>
$gitlab->keep_artifacts( :pid, :job_id );
Prevents artifacts from being deleted when expiration is set.
=item L<job_play()|https://docs.gitlab.com/ee/api/jobs.html#play-a-job>
$gitlab->job_play( :pid, :job_id );
Triggers a manual action to start a job.
=back
=head1 AUTHOR
Roman Lacko <L<xlacko1@fi.muni.cz>>
=head1 SEE ALSO
=over
=item L<GitLab>
Wrapper around L<GitLab::API> and other C<GitLab::*> modules.
=back
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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