X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=jjb-compare-xml.sh;h=740daf3612e48bea4f24ac7f9576c53a63768192;hb=refs%2Fheads%2Fv0.21.x;hp=5017674b025746a7928b36ee964d383813751c98;hpb=cee820144e0741dee01b9eb755827f2c263a0cf8;p=releng%2Fglobal-jjb.git diff --git a/jjb-compare-xml.sh b/jjb-compare-xml.sh index 5017674b..740daf36 100755 --- a/jjb-compare-xml.sh +++ b/jjb-compare-xml.sh @@ -9,16 +9,28 @@ # http://www.eclipse.org/legal/epl-v10.html ############################################################################## -# This script tests jjb templates by comparing the result with expected output. +# This script tests jjb templates by comparing the result with expected output +# from global-jjb's origin/master branch. test_dir=$(mktemp -d) script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -expected_xml_dir="$script_dir/jjb-test/expected-xml" +expected_xml_dir="$(mktemp -d -t gjjb-XXXXXXXX)" echo "Script Directory: $script_dir" echo "Test Directory: $test_dir" +echo "Expected XML Directory: $expected_xml_dir" -jenkins-jobs test --recursive -o "$test_dir" "$script_dir" +git fetch origin +gittmp="$(mktemp -d)" +git worktree add --detach "$gittmp" origin/master +pushd "$gittmp" || exit +echo "Generating expected XML." +jenkins-jobs test --recursive -o "$expected_xml_dir" "$gittmp":.jjb-test > /dev/null 2>&1 +popd || exit +rm -r "$gittmp" + +echo "Generating test XML." +jenkins-jobs test --recursive -o "$test_dir" "$script_dir":.jjb-test fail=false for xml in "$test_dir"/*; do @@ -30,10 +42,20 @@ for xml in "$test_dir"/*; do fi done +echo "Checking for double curly braces..." +mapfile -t xml_files < <(find "$test_dir" -type f) +for xml in "${xml_files[@]}"; do + if grep '{{' "$xml"; then + echo "ERROR: Double curly braces discovered in output XML." + exit 1 + fi +done +echo "No double curly braces found." + # Cleanup -rm -rf "$test_dir" +rm -rf "$test_dir" "$expected_xml_dir" if $fail; then - echo "Differences detected. Check above for jobs that have been changed." - exit 1 + echo "WARN: Differences detected. Check above for jobs that have been changed." + exit 0 fi