diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:32:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:32:59 +0000 |
commit | 4d57e0a8dab2139a631a21aab862487481548702 (patch) | |
tree | f7cea0b9939e2ecb7a301de6c83bada29452046d /lib/Devscripts/Salsa/pipeline_schedules.pm | |
parent | Initial commit. (diff) | |
download | devscripts-4d57e0a8dab2139a631a21aab862487481548702.tar.xz devscripts-4d57e0a8dab2139a631a21aab862487481548702.zip |
Adding upstream version 2.23.7.upstream/2.23.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/Devscripts/Salsa/pipeline_schedules.pm')
-rwxr-xr-x | lib/Devscripts/Salsa/pipeline_schedules.pm | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/lib/Devscripts/Salsa/pipeline_schedules.pm b/lib/Devscripts/Salsa/pipeline_schedules.pm new file mode 100755 index 0000000..66ad08a --- /dev/null +++ b/lib/Devscripts/Salsa/pipeline_schedules.pm @@ -0,0 +1,73 @@ +# Lists pipeline schedules of a project +package Devscripts::Salsa::pipeline_schedules; + +use strict; +use Devscripts::Output; +use Moo::Role; + +# For --all +with "Devscripts::Salsa::Repo"; + +sub pipeline_schedules { + my ($self, @repo) = @_; + my $ret = 0; + + unless (@repo or $self->config->all) { + ds_warn "Usage $0 pipelines <project|--all>"; + return 1; + } + if (@repo and $self->config->all) { + ds_warn "--all with a project (@repo) makes no sense"; + return 1; + } + + # If --all is asked, launch all projects + @repo = map { $_->[1] } $self->get_repo(0, @repo) unless (@repo); + + foreach my $p (sort @repo) { + my $id = $self->project2id($p); + my $count = 0; + unless ($id) { + #ds_warn "Project $p not found"; # $self->project2id($p) shows this error + $ret++; + unless ($self->config->no_fail) { + ds_verbose "Use --no-fail to continue"; + return 1; + } + } else { + my $projects = $self->api->project($id); + if ($projects->{jobs_enabled} == 0) { + print "$p has disabled CI/CD\n"; + next; + } + + my $pipelines + = $self->api->paginator('pipeline_schedules', $id)->all(); + + print "$p\n" if @$pipelines; + + foreach (@$pipelines) { + my $status = $_->{active} ? 'Enabled' : 'Disabled'; + print <<END; +\tID : $_->{id} +\tDescription: $_->{description} +\tStatus : $status +\tRef : $_->{ref} +\tCron : $_->{cron} +\tTimezone : $_->{cron_timezone} +\tCreated : $_->{created_at} +\tUpdated : $_->{updated_at} +\tNext run : $_->{next_run_at} +\tOwner : $_->{owner}->{username} + +END + } + } + unless ($count) { + next; + } + } + return $ret; +} + +1; |