How to fix script config should be a string or a nested array of strings up to 10 levels deep?

With below pipeline job, I am getting syntax error.

    Found errors in your .gitlab-ci.yml:
    jobs:test-artifact:script config should be a string or a nested array of strings up to 10 levels deep
    You can also test your .gitlab-ci.yml in CI Lint

Some one suggested to keep the : part in double quotes but it is already part of it.

      stage: build
      allow_failure: false
      needs: ["build-rpm"]
      dependencies:  # This is what gets the artifacts from the previous job
        - build-rpm
        - .ifadmindeploy
      image: ubuntu:latest
        - yum update -y && yum install -y curl
        - echo $CI_JOB_TOKEN
        - mkdir test && cd test 
        - curl --location --output --header "JOB-TOKEN: $CI_JOB_TOKEN" "${CI_JOB_ID}/artifacts" 
        - curl --location --output --header "JOB-TOKEN: $CI_JOB_TOKEN" "${CI_JOB_ID}/artifacts"
        - curl --location --output pipeline.rpm --header "JOB-TOKEN: $CI_JOB_TOKEN" "${CI_JOB_ID}/artifacts/raw/dist/myproject-dev-default-nightlye2e.x86_64.rpm"
        - curl --location --output pipeline.rpm --header "JOB-TOKEN: $CI_JOB_TOKEN" "${CI_JOB_ID}/artifacts/raw/dist/myproject-dev-default-nightlye2e.x86_64.rpm"
        - ls -la

So, the lint is getting hung up on --header "JOB-TOKEN: $CI_JOB_TOKEN". If you take that out, then the lint can parse the config.

You might be able to mess around with quoting and escaping to make it work, but curl can read headers from a file, so it might be easier just to cat the headers to a file on disk and read them from there.

As per your suggestion, I tried like this.
below worked first

- "curl --location --output pipeline.rpm --header \"JOB-TOKEN: $CI_JOB_TOKEN\" \"${CI_JOB_ID}/artifacts/raw/dist/project-n-dev-default-nightlye2e.x86_64.rpm\""

but when I variable assignment, it is failing again.

   - rpmdownload="curl --location --output pipeline.rpm --header \"JOB-TOKEN: $CI_JOB_TOKEN\" \"${CI_JOB_ID}/artifacts/raw/dist/project-n-dev-default-nightlye2e.x86_64.rpm\""
    - echo $rpmdownload

That wasn’t my suggestion, I was thinking of something like this:

    - cat "JOB-TOKEN: ${CI_JOB_TOKEN}" >headers.txt
    - curl --location --output --header @headers.txt${CI_JOB_ID}/artifacts

that won’t be possible as we want to use this command in the terraform aws ec2 user-data section.
can you suggest any other options.

the main idea is to copy this rpm tp the ec2 machine and use that in the user-data section of it.
file provision will happen only after user-data, so thought to use the link directly in the userdata with curl command.

Now not getting error if I move the variable assignment to variables section instead of script section.

But getting error with sed.

echo $rpmdownload
curl --location --output pipeline.rpm --header "JOB-TOKEN: [MASKED]" ""
vagrant@vagrant:~/aws/admin-server$ cat i.txt
yum -y update
yum update -y
vagrant@vagrant:~/aws/admin-server$ sed -i "s/yum -y update/${rpmdownload}; yum -y update/g" i.txt
sed: -e expression #1, char 86: unknown option to `s'

For simple strings, it is working. But for the above string, getting error as in last line.

Please suggest.

Use single quote

or use long commands