diff --git a/scripts/generate-pipeline.sh b/scripts/generate-pipeline.sh index 0a1f8ec..4dd0c41 100755 --- a/scripts/generate-pipeline.sh +++ b/scripts/generate-pipeline.sh @@ -86,13 +86,16 @@ ${needs_section} VALIDATE_JOB - # Plan needs для secrets - ждём plan зависимостей + # Plan needs и before_script для secrets plan_needs="validate-${job_prefix}" + plan_before_script="cd \$TG_ROOT && ls -la" if [ "$component" = "secrets" ]; then plan_needs="validate-${job_prefix} - plan-${env}-namespace - plan-${env}-s3 - plan-${env}-database" + # Для secrets инициализируем зависимости чтобы получить их outputs + plan_before_script="cd ../namespace && terragrunt init -upgrade -reconfigure && cd ../s3 && terragrunt init -upgrade -reconfigure && cd ../database && terragrunt init -upgrade -reconfigure && cd \$TG_ROOT && ls -la" fi cat >> "$OUTPUT_FILE" << PLAN_JOB @@ -106,8 +109,7 @@ plan-${job_prefix}: needs: - ${plan_needs} before_script: - - cd \$TG_ROOT - - ls -la + - ${plan_before_script} script: - terragrunt init -upgrade -reconfigure - terragrunt plan -out=tfplan @@ -130,11 +132,14 @@ PLAN_JOB when_clause="manual" apply_needs="plan-${job_prefix}" + apply_before_script="cd \$TG_ROOT && ls -la" if [ "$component" = "secrets" ]; then apply_needs="plan-${job_prefix} - apply-${env}-namespace - apply-${env}-s3 - apply-${env}-database" + # Для secrets инициализируем зависимости чтобы получить их outputs + apply_before_script="cd ../namespace && terragrunt init -upgrade -reconfigure && cd ../s3 && terragrunt init -upgrade -reconfigure && cd ../database && terragrunt init -upgrade -reconfigure && cd \$TG_ROOT && ls -la" fi cat >> "$OUTPUT_FILE" << APPLY_JOB @@ -145,12 +150,10 @@ apply-${job_prefix}: TG_ROOT: "${full_component_dir}" ENVIRONMENT: "${env}" YC_FOLDER_ID: "\$${folder_var}" - TG_SKIP_DEPENDENCY_OUTPUTS: "false" needs: - ${apply_needs} before_script: - - cd \$TG_ROOT - - ls -la + - ${apply_before_script} script: - terragrunt init -upgrade -reconfigure - terragrunt apply -auto-approve