So I'm not sure if this is actually a Bash issue or a Tekton issue. The problem occurs in my OpenShift (Tekton) pipeline. After having deployed my application, I have a step where I need to check if the Deployment
has actually been created.
This is done like this:
until oc get deployment.apps/my-app-foo &> /dev/null
do
echo .
sleep 2
done
In the snippet above, I've hardcoded the name of the Deployment
"my-app". The suffix "-foo" is part of every Deployment
resource. When hardcoded, it works, and I get my Deployment
, as expected.
When I try to parameterize the name of the Deployment
, my pipeline fails with the following error:
Error from server (NotFound): deployments.apps "my-app" not found
.
Error from server (NotFound): deployments.apps "my-app" not found
.
Error from server (NotFound): deployments.apps "my-app" not found
.
So the issue is obviously that the "-foo" suffix isn't added to my variable, and I can't figure out how to do this. Tried replacing the parentheses with curly braces, tried double quotes around the entire expression, and a few other variants.
Here's my code with variable substitution:
until oc get deployment.apps/$(params.pod-name)-foo &> /dev/null
do
echo .
sleep 2
done
Can anyone tell what I'm doing wrong?
CodePudding user response:
Not entirely sure what the issue is, but seems it has something to do with Tekton variable substitution syntax.
Anyway, I managed to work around it by assigning the Tekton parameter to a bash variable, like this:
POD_NAME=$(params.pod-name)
SUFFIX='-foo'
And then I used these variables straight forward in the until loop like this:
until oc get deployment.apps/${POD_NAME}${SUFFIX} &> /dev/null
do
echo .
sleep 2
done
PS. The suffix would probably work fine without being put in a variable, but I'm using it some other places in the same script, so that's why I put it there.