[salsa] Add pipeline schedule support
REF:
This can only be merged in now, however --schedule-run
will not work.
This requires bluefeet/GitLab-API-v4 #55 to be merged upstream and then have the Debian package updated (libgitlab-api-v4-perl).
GitLab CI will currently fail for a different reason: !313 (merged)
This is based on:
./lib/Devscripts/Salsa/last_ci_status.pm
./lib/Devscripts/Salsa/merge_request.pm
./lib/Devscripts/Salsa/merge_requests.pm
Setup
Mimicking GitLab runners:
% docker run --rm --interactive --tty --entrypoint=/bin/bash --hostname debian --volume $(pwd):/builds/g0tmi1k/devscripts/ --workdir /builds/g0tmi1k/devscripts/ debian:unstable
# export PERL5LIB=/builds/g0tmi1k/devscripts/lib/
# cat .gitlab-ci.yml
[...]
#
conf-file
Looking to see there isn't any pipelines currently:
# perl scripts/salsa.pl --conf-file config.conf --debug --verbose pipelines test123
[...]
#
Check options/config file:
# grep SALSA_SCHEDULE_ lib/Devscripts/Salsa/Config.pm | cut -d "'" -f 4
SALSA_SCHEDULE_DESC
SALSA_SCHEDULE_REF
SALSA_SCHEDULE_CRON
SALSA_SCHEDULE_TZ
SALSA_SCHEDULE_ENABLE
SALSA_SCHEDULE_DISABLE
SALSA_SCHEDULE_RUN
SALSA_SCHEDULE_DELETE
#
# grep SALSA_SCHEDULE_ config.conf
SALSA_SCHEDULE_DESC="Test pipeline"
SALSA_SCHEDULE_REF="main"
SALSA_SCHEDULE_CRON="0 0 * * *"
SALSA_SCHEDULE_TZ="UTC"
SALSA_SCHEDULE_ENABLE=yes
SALSA_SCHEDULE_RUN=yes
#
Run and then see new pipeline
# perl scripts/salsa.pl --conf-file config.conf --debug --verbose pipeline test123
[...]
# perl scripts/salsa.pl --conf-file config.conf --debug --verbose pipelines test123
[...]
#
Disable after:
# sed -i 's|^SALSA_SCHEDULE_|#SALSA_SCHEDULE_|g' config.conf
#
Command line arguments
Quick way to see flags:
# grep 'item.*--schedule-' ./scripts/salsa.pl
=item B<--schedule-desc>
=item B<--schedule-ref>
=item B<--schedule-cron>
=item B<--schedule-tz>
=item B<--schedule-enable>, B<--schedule-disable>
=item B<--schedule-run>
=item B<--schedule-delete>
#
Run with arguments:
# perl scripts/salsa.pl --conf-file config.conf --debug --verbose pipeline test123 --schedule-desc="Another test for %p" --schedule-ref="main" --schedule-cron="1 1 * * *" --schedule-tz=UTC --schedule-enable
[...]
Run again with the same arguments, should edit (but nothing change):
# !!
[...]
# perl scripts/salsa.pl --conf-file config.conf --debug --verbose pipelines test123
[...]
Run again with different arguments, should edit:
# perl scripts/salsa.pl --conf-file config.conf --debug --verbose pipeline test123 --schedule-desc="Another test for %p" --schedule-disable
[...]
# perl scripts/salsa.pl --conf-file config.conf --debug --verbose pipelines test123
[...]
Execute pipeline now, and then delete afterwards:
# perl scripts/salsa.pl --conf-file config.conf --debug --verbose pipeline test123 --schedule-desc="Another test for %p" --schedule-run --schedule-delete
[...]
# perl scripts/salsa.pl --conf-file config.conf --debug --verbose pipelines test123
[...]