Gitlab-ci "if then curl" error

Hello!
i try use if then else in gitlab-ci, but have error when ci executing.
if i ty this:

version:
 stage: getimageversion
 before_script:
   - apk add --no-cache curl jq
 script:
   - GITLAB_URL=$(echo ${CI_PROJECT_URL} |awk -F "/" '{print $1 "//" $2$3}')
   - echo ${GITLAB_URL}
   - echo ${IMAGE_VERSION}
   - echo ${CI_PROJECT_ID}
   - "VAR=$(curl -s -f  --header \"PRIVATE-TOKEN: ${TOKEN}\" \"${GITLAB_URL}/api/v4/projects/${CI_PROJECT_ID}/variables/${IMAGE_FROM_PRJ}\" | jq  -r '.value' ) " 

all work fine. But if i try replace:

  • “VAR=(curl -s -f --header \"PRIVATE-TOKEN: {TOKEN}” “{GITLAB_URL}/api/v4/projects/{CI_PROJECT_ID}/variables/${IMAGE_FROM_PRJ}” | jq -r ‘.value’ ) "

to

  • if [ -z "{IMAGE_FROM_TRX}" ]; then VAR=(curl -s -f --header “PRIVATE-TOKEN: {TOKEN}\" \"{GITLAB_URL}/api/v4/projects/{CI_PROJECT_ID}/variables/{IMAGE_FROM_PRJ}” | jq -r ‘.value’ ) "; fi

i have warning: incorrect type. Expected “string”

Hello @acidborn60, welcome to forum.

Try this

value’ ) ; fi

Instance of

value’ ) "; fi

Quote missing :slight_smile: