Sample Header Ad - 728x90

How to split long commands containing special character into multiline commands?

0 votes
1 answer
102 views
I have been reading documentation from gitlab at: * https://docs.gitlab.com/ee/ci/yaml/script.html#split-long-commands In my case I have a special character (colon ':'), so I also did read: * https://docs.gitlab.com/ee/ci/yaml/script.html#use-special-characters-with-script Now my question is: how do I combine both ? On one hand I have (ref ):
job name:
  script:
    - |
      for file in *; do
        echo "$file";
        echo "${REPO}/${file}";
      done
And on the other hand I have (ref ):
script:
    - 'for file in *; do curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${file}" "${REPO}/${file}"; done'
How do I combine both ? Long term solution is to handle error in my for loop as (ref ):
- 'http_code=$(curl -o /dev/null -s -w "%{http_code}" --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "$file" "${REPO}/${file}")'
    - if [ $http_code -ne 201 ]; then echo "Upload failed: terminating" && false; fi;
Asked by malat (3429 rep)
Jun 28, 2023, 11:54 AM
Last activity: Jul 17, 2023, 08:39 AM