From 52c84f656eabca56b2f05dc51da1ba098dee83f6 Mon Sep 17 00:00:00 2001 From: Lee Goolsbee Date: Fri, 26 Sep 2025 10:30:51 -0500 Subject: [PATCH] ITPLT-4544 fix template check logic --- bitbucket-pipelines.yml | 12 +++++------- .../templates/bitbucket-pipelines.yml.j2 | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 92dff08..2b46e2a 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -36,13 +36,11 @@ pipelines: name: Check if the template is up-to-date script: - | - actual_scenario_count=$(find ./roles -type f -name "molecule.yml" -exec dirname {} ';' | wc -l | sed -e 's/^[[:space:]]*//') - grep "Running tests in ${actual_scenario_count} batches" bitbucket-pipelines.yml - GREP_RETURN_CODE=$? - if [[ $GREP_RETURN_CODE -ne 0 ]]; then - echo "Mismatch between expected and actual number [${actual_scenario_count}] of scenarios. Please look at https://bitbucket.org/atlassian/dc-deployments-automation/src/master/DEVELOPMENT.md for instructions on how to fix this error." - exit $GREP_RETURN_CODE - fi + actual_scenario_count=$(find ./roles -type f -name "molecule.yml" -exec dirname {} ';' | wc -l | sed -e 's/^[[:space:]]*//') + if ! grep -q "Running tests in ${actual_scenario_count} batches" bitbucket-pipelines.yml; then + echo "Mismatch between expected (39) and actual number (${actual_scenario_count}) of scenarios. Please look at https://bitbucket.org/atlassian/dc-deployments-automation/src/master/DEVELOPMENT.md for instructions on how to fix this error." + exit 1 + fi - parallel: - step: diff --git a/pipeline_generator/templates/bitbucket-pipelines.yml.j2 b/pipeline_generator/templates/bitbucket-pipelines.yml.j2 index c9c3208..7839a1f 100644 --- a/pipeline_generator/templates/bitbucket-pipelines.yml.j2 +++ b/pipeline_generator/templates/bitbucket-pipelines.yml.j2 @@ -36,13 +36,11 @@ pipelines: name: Check if the template is up-to-date script: - | - actual_scenario_count=$(find ./roles -type f -name "molecule.yml" -exec dirname {} ';' | wc -l | sed -e 's/^[[:space:]]*//') - grep "Running tests in ${actual_scenario_count} batches" bitbucket-pipelines.yml - GREP_RETURN_CODE=$? - if [[ $GREP_RETURN_CODE -ne 0 ]]; then - echo "Mismatch between expected and actual number [${actual_scenario_count}] of scenarios. Please look at https://bitbucket.org/atlassian/dc-deployments-automation/src/master/DEVELOPMENT.md for instructions on how to fix this error." - exit $GREP_RETURN_CODE - fi + actual_scenario_count=$(find ./roles -type f -name "molecule.yml" -exec dirname {} ';' | wc -l | sed -e 's/^[[:space:]]*//') + if ! grep -q "Running tests in ${actual_scenario_count} batches" bitbucket-pipelines.yml; then + echo "Mismatch between expected ({{ scenario_paths|length }}) and actual number (${actual_scenario_count}) of scenarios. Please look at https://bitbucket.org/atlassian/dc-deployments-automation/src/master/DEVELOPMENT.md for instructions on how to fix this error." + exit 1 + fi - parallel: {% for spath in scenario_paths %}