IFThenElse
IFThenElse

Reputation: 228

Differnce between linux shell skript and Gitlab shell script

I have a pipeline that always fail with a shell command. This is:

response=$(curl -s -u "${HARBOR_SWIO_USER}:${HARBOR_SWIO_PASS}" -H "Accept:application/json" "$URL")

#This line will fail
echo "$response" | jq -e --arg TAG "$TAG" '.[]|select(.tags[].name==$TAG)' > /dev/null

if [ $? -eq 0 ]; then
    echo "Image exists"
else
    echo "Image does not exist"
fi

I put this into a shell script on my Linux and execute it, works well. On Gitlab with a Linux Runner it fails.

I checked the jq version, both 1.6 I verified the JSON from response with JQ and this is successful (0).

echo $response | jq -e . >/dev/null 2>&1  ; echo ${PIPESTATUS[1]}

But everytime the first call fail on Gitlab. Any Idea what is wrong?

Upvotes: 0

Views: 26

Answers (1)

Sagar Karki
Sagar Karki

Reputation: 1

response=$(curl -s -u "${HARBOR_SWIO_USER}:${HARBOR_SWIO_PASS}" -H "Accept:application/json" "$URL")

#This line will fail echo "$response" | jq -e --arg TAG "$TAG" '.[]|select(.tags[].name==$TAG)' > /dev/null

if [ $? -eq 0 ]; then echo "Image exists" else echo "Image does not exist"

Upvotes: -2

Related Questions