vendredi 12 juin 2020

Failure in if else , then condition in shell [duplicate]

I want when my bitbucket branch name is not Develop or master, export current_branch_jira=$current_branch command should run. But whenever, I am trying the above code in a ubuntu VM inside bitbucket pipeline, it fails with error "Syntax error: "(" unexpected (expecting "then")". But the above script is working well in my AWS ubuntu VM

I feel, I am wrong in if condition.

#!/bin/bash
if [[ ! $BITBUCKET_BRANCH =~ ^(Develop|master)$ ]]; then
  export current_branch_jira=$current_branch
  echo $current_branch_jira
else
  echo "No Change because of $BITBUCKET_BRANCH branch is not a feature branch"
fi

Aucun commentaire:

Enregistrer un commentaire