Commit 430a9734 authored by sagnowski's avatar sagnowski
Browse files

Try to set variables within the script

parent 185466b1
Loading
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -406,24 +406,29 @@ clang-format-check:
    - .rules-merge-request
  variables:
    ARTIFACT_BASE_NAME: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--formatting-fix"
    INSTRUCTIONS_GITLAB: 'To fix formatting issues:\n
      - download the diff patch available as artifact of this job\n
      - unzip the artifact and place the patch file in the root directory of your local IVAS repo\n
      - run: git apply "$ARTIFACT_BASE_NAME".patch\n
      - commit new changes'
    INSTRUCTIONS_README: 'To fix formatting issues:\n
      - place the patch file in the root directory of your local IVAS repo\n
      - run: git apply "$ARTIFACT_BASE_NAME".patch\n
      - commit new changes'
  stage: validate
  needs: []
  timeout: "5 minutes"
  script:
    # Set up variables. This can't be done in the "variables" section because variables are not expanded properly there
    - PATCH_FILE_NAME="$ARTIFACT_BASE_NAME".patch
    - >
      INSTRUCTIONS_GITLAB="To fix formatting issues:
      - download the diff patch available as artifact of this job
      - unzip the artifact and place the patch file in the root directory of your local IVAS repo
      - run: git apply $PATCH_FILE_NAME
      - commit new changes"
    - >
      INSTRUCTIONS_README="To fix formatting issues:
      - place the patch file in the root directory of your local IVAS repo
      - run: git apply $PATCH_FILE_NAME
      - commit new changes"
    
    - scripts/check-format.sh -af -p 8 || format_problems=$?
    - if [ $format_problems == 0 ] ; then exit 0; fi

    - mkdir tmp-formatting-fix
    - git diff > "tmp-formatting-fix/$ARTIFACT_BASE_NAME.patch"
    - git diff > "tmp-formatting-fix/$PATCH_FILE_NAME"

    # Print instructions to job output
    - echo -e "$INSTRUCTIONS_GITLAB"