Skip to content
Advertisement

If condition is failing in the GitLab CI

following is my Gitlab CI code:-

JavaScript

I’m trying to validate the JIRA status by calling its API after retrieving Jira id from title of Merge Request. There is a problem in the If condition below if [[ "$JIRA_STATUS" == "^(Done|Completed|Closed)$" ]] as it is not validating it properly. Every time, the else condition is getting executed and printing the message as Valid JIRA Id found! I would really appreciate if someone can help me to fix this minor issue. I want to gracefully exit the job with this message in the if block as Invalid JIRA (Done/Completed/Closed) found! whenever the Jira status found to be in any of the given values as Done, Completed or Closed.

Advertisement

Answer

I’m finally able to resolve this issue by modifying the code like below:-

JavaScript

I had used the test command along with if-else condition in Linux to make it work

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement