summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Zorn <christopherzo@zillowgroup.com>2020-04-08 17:02:29 -0700
committerChristopher Zorn <christopherzo@zillowgroup.com>2020-04-20 16:18:04 -0700
commit07b99881dfa6efa9665245647460e99846ccd341 (patch)
tree0ad774c01fdf6045c36eea3be35cf0ab16136273
parent7907e5a4b602d22d03d71ca51c6803f634bd8a78 (diff)
downloadgitlab-07b99881dfa6efa9665245647460e99846ccd341.tar.gz
feat: add play command to project pipeline schedules
fix: remove version from setup feat: add pipeline schedule play error exception docs: add documentation for pipeline schedule play
-rw-r--r--docs/gl_objects/pipelines_and_jobs.rst5
-rw-r--r--gitlab/exceptions.py4
-rw-r--r--gitlab/v4/objects.py18
3 files changed, 27 insertions, 0 deletions
diff --git a/docs/gl_objects/pipelines_and_jobs.rst b/docs/gl_objects/pipelines_and_jobs.rst
index 30b45f2..c79d19f 100644
--- a/docs/gl_objects/pipelines_and_jobs.rst
+++ b/docs/gl_objects/pipelines_and_jobs.rst
@@ -155,6 +155,11 @@ Update a schedule::
sched.cron = '1 2 * * *'
sched.save()
+Trigger a pipeline schedule immediately::
+
+ sched = projects.pipelineschedules.get(schedule_id)
+ sched.play()
+
Delete a schedule::
sched.delete()
diff --git a/gitlab/exceptions.py b/gitlab/exceptions.py
index f95e686..fd2ff2a 100644
--- a/gitlab/exceptions.py
+++ b/gitlab/exceptions.py
@@ -145,6 +145,10 @@ class GitlabJobEraseError(GitlabRetryError):
pass
+class GitlabPipelinePlayError(GitlabRetryError):
+ pass
+
+
class GitlabPipelineRetryError(GitlabRetryError):
pass
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 756ec4f..f6c09d9 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -3775,6 +3775,24 @@ class ProjectPipelineSchedule(SaveMixin, ObjectDeleteMixin, RESTObject):
server_data = self.manager.gitlab.http_post(path, **kwargs)
self._update_attrs(server_data)
+ @cli.register_custom_action("ProjectPipelineSchedule")
+ @exc.on_http_error(exc.GitlabPipelinePlayError)
+ def play(self, **kwargs):
+ """Trigger a new scheduled pipeline, which runs immediately.
+ The next scheduled run of this pipeline is not affected.
+
+ Args:
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabPipelinePlayError: If the request failed
+ """
+ path = "%s/%s/play" % (self.manager.path, self.get_id())
+ server_data = self.manager.gitlab.http_post(path, **kwargs)
+ self._update_attrs(server_data)
+ return server_data
+
class ProjectPipelineScheduleManager(CRUDMixin, RESTManager):
_path = "/projects/%(project_id)s/pipeline_schedules"