diff --git a/script/openqa-clone-custom-git-refspec b/script/openqa-clone-custom-git-refspec index cc3d1d15facc..3d1c9da7be82 100755 --- a/script/openqa-clone-custom-git-refspec +++ b/script/openqa-clone-custom-git-refspec @@ -7,13 +7,15 @@ Usage: openqa-clone-custom-git-refspec [CUSTOM_TEST_VAR_1=foo] [CUSTOM_TEST_VAR_2=bar] ... Options: - -v, --verbose execute with verbose output - -h, -?, --help display this help - -n, --dry-run execute in dry-run mode, do not clone any openQA jobs + -v, --verbose execute with verbose output + -h, -?, --help display this help + -n, --dry-run execute in dry-run mode, do not clone any openQA jobs + -c --clone-job-args pass additional parameters to 'openqa-clone-job', e.g. '--clone-job-args="--show-progress"' Examples: openqa-clone-custom-git-refspec https://github.com/os-autoinst/os-autoinst-distri-opensuse/pull/6529 https://openqa.opensuse.org/tests/835060 DESKTOP=textmode openqa-clone-custom-git-refspec https://github.com/coolgw/os-autoinst-distri-opensuse/tree/nfs https://openqa.opensuse.org/tests/835060 DESKTOP=textmode + openqa-clone-custom-git-refspec -n -c '--show-progress' https://github.com/coolgw/os-autoinst-distri-opensuse/tree/nfs https://openqa.opensuse.org/tests/835060 DESKTOP=textmode EOF exit } @@ -35,13 +37,14 @@ throw_json_error() { exit 2 } -opts=$(getopt -o vhn --long verbose,dry-run,help -n 'parse-options' -- "$@") || usage +opts=$(getopt -o vhnc: --long verbose,dry-run,help,clone-job-args: -n 'parse-options' -- "$@") || usage eval set -- "$opts" while true; do case "$1" in -v | --verbose ) set -x; shift ;; -h | --help ) usage; shift ;; -n | --dry-run ) dry_run=true; shift ;; + -c | --clone-job-args ) clone_args="$2 $clone_args"; shift 2 ;; -- ) shift; break ;; * ) break ;; esac @@ -108,7 +111,7 @@ clone_job() { local casedir="${casedir:-"$repo#$branch"}" local GROUP="${GROUP:-0}" local dry_run="${dry_run:-""}" - local cmd="$dry_run openqa-clone-job \"$clone_args\" \"$host\" \"$job\" _GROUP=\"$GROUP\" TEST=\"$test\" BUILD=\"$build\" CASEDIR=\"$casedir\" PRODUCTDIR=\"$productdir\" NEEDLES_DIR=\"$needles_dir\"" + local cmd="$dry_run openqa-clone-job $clone_args \"$host\" \"$job\" _GROUP=\"$GROUP\" TEST=\"$test\" BUILD=\"$build\" CASEDIR=\"$casedir\" PRODUCTDIR=\"$productdir\" NEEDLES_DIR=\"$needles_dir\"" cmd=$cmd"$(printf " '%s'" "${args[@]}")" if [[ -n "$MARKDOWN" ]]; then eval "$cmd" | sed 's/^Created job.*: \([^ ]*\) -> \(.*\)$/* [\1](\2)/' diff --git a/t/40-script_openqa-clone-custom-git-refspec.t b/t/40-script_openqa-clone-custom-git-refspec.t index cd5fce6dfed3..d0ffe9cbc78a 100644 --- a/t/40-script_openqa-clone-custom-git-refspec.t +++ b/t/40-script_openqa-clone-custom-git-refspec.t @@ -67,12 +67,15 @@ combined_like sub { $ret = run_once('', $prefix) }, $expected_custom_re, 'testsu is $ret, 0, 'exits successfully'; my $args_trailing = 'https://github.com/me/repo/pull/1/ https://openqa.opensuse.org/tests/1'; test_once $args_trailing, qr{TEST=my_test\@user/repo#my_branch.*}, 'trailing slash ignored'; -$args .= ',https://openqa.opensuse.org/tests/1234'; +my $args_list = $args . ',https://openqa.opensuse.org/tests/1234'; $expected_re = qr/${expected}.*opensuse.org 1234/s; -test_once $args, $expected_re, 'accepts comma-separated list of jobs'; -$args .= ' FOO=bar'; +test_once $args_list, $expected_re, 'accepts comma-separated list of jobs'; +$args_list .= ' FOO=bar'; $expected_re = qr/${expected} FOO=bar.*opensuse.org 1234.*FOO=bar/s; -test_once $args, $expected_re, 'additional arguments are passed as test parameters for each job'; +test_once $args_list, $expected_re, 'additional arguments are passed as test parameters for each job'; +my $args_clone = '--clone-job-args="--show-progress" ' . $args; +$expected_re = qr/openqa-clone-job --show-progress --skip-chained-deps --within-instance https/; +test_once $args_clone, $expected_re, 'additional parameters can be passed to clone-job'; my $args_escape = q(https://github.com/me/repo/pull/1/ https://openqa.opensuse.org/tests/1 TEST1=$FOO_BAR 'TEST2=$VAR' TEST3=space\\ space 'TEST4=(!?bla)');