1

With below pipeline job, I am getting syntax error.

gitlab 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.

test-artifact:
  stage: build
  allow_failure: false
  needs: ["build-rpm"]
  dependencies:  # This is what gets the artifacts from the previous job
    - build-rpm
  extends:
    - .ifadmindeploy
  image: ubuntu:latest
  script:
    - yum update -y && yum install -y curl
    - echo $CI_JOB_TOKEN
    - mkdir test && cd test 
    - curl --location --output artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://myproject.gitlab.io/-/product/-/jobs/${CI_JOB_ID}/artifacts" 
    - curl --location --output artifacts1.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://gitlab.com/myproject/product/-/jobs/${CI_JOB_ID}/artifacts"
    - curl --location --output pipeline.rpm --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://gitlab.com/myproject/product/-/jobs/${CI_JOB_ID}/artifacts/raw/dist/myproject-dev-default-nightlye2e.x86_64.rpm"
    - curl --location --output pipeline.rpm --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://myproject.gitlab.io/-/product/-/jobs/${CI_JOB_ID}/artifacts/raw/dist/myproject-dev-default-nightlye2e.x86_64.rpm"
    - ls -la
Kalel
  • 244
  • The problem is with the colon(:) character within your script. Either you remove totally the ':' character or you surround the command(s) containing the ':' character with the single-quote character ('). I think it somehow affects and misleads the way Gitlab parses the script command. – Iwan Satria Sep 14 '23 at 08:34

2 Answers2

1

If you surround the entire command with ' ' brackets this should rectify the issue.

Something like the following:

'curl --location --output artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://myproject.gitlab.io/-/product/-/jobs/${CI_JOB_ID}/artifacts"'

Keep in mind this will not work if you are already using ' ' brackets inside the command, still working out how to resolve that!

thavart
  • 11
0

you can use Pipe symbol '|' something like:-

  script:
    - yum update -y && yum install -y curl
    - echo $CI_JOB_TOKEN
    - mkdir test && cd test 
    _ |
      curl --location --output artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://myproject.gitlab.io/-/product/-/jobs/${CI_JOB_ID}/artifacts"