Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have this code in a yaml file. This file gets run when I run docker.
if [[ $EXITCODE -ne 0 && "$CI_COMMIT_BRANCH" == "staging" ]] || [[ $EXITCODE -ne 0 && "$CI_COMMIT_BRANCH" == "develop" ]]; then
echo "Hello"
When I run these lines of code in my terminal it works as it should.
But when I run this file via docker, I get this error
sh: 0: unknown operand
What is happening here? Why am I getting this error? I've tried using different syntax for the $EXITCODE and the 0 but still getting the same error
–
–
–
Thank you everyone for your response!
So this works
if [[ "$EXITCODE" == "0" && "$CI_COMMIT_BRANCH" == "staging" ]] || [[ $EXITCODE -ne 0 && "$CI_COMMIT_BRANCH" == "develop" ]]; then
echo "Hello"
I guess it didn't like -ne
.
However I have used
if [[ $EXITCODE -ne 0 ]]; then
echo "Hello"
and it has worked on its own. I guess you can't use it when there are other conditions and it's using the ==
or !=
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.