Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the code like below. It is from circleCi = ci/cd tool , this use shell script also.
The problem: When I pass test_branch or master directly like this --data '{ "branch": "master" }' It works fine. But I need to pass a parameter. When I run the config with parameter, I see info: Branch not found I have tried "${CIRCLE_BRANCH}" also but does not work
Could you tell me how to pass a generic value there ?

if [ "$CIRCLE_BRANCH" = "test_branch" ] || [ "$CIRCLE_BRANCH" = "master" ]; then

               curl -X POST \
               --header "Circle-Token: $CIRCLECI_API_TOKEN" \
               --header 'Accept: application/json' \
               --header 'Content-Type: application/json' \
               --url https://circleci.com/api/v2/project/bitbucket/......... \
               --data '{ "branch": "$CIRCLE_BRANCH" }'     
 fi  


What I have tried:

Many trying but not work ......
Posted
Comments
Richard MacCutchan 27-Sep-20 3:41am    
Which line does the error message appear on? Also, it is not clear what you mean by "But I need to pass a parameter". The code above only accepts one of two parameter values as shown in the first line.
Member 13702159 27-Sep-20 4:34am    
The error which I get is: Branch not found, it means that in this line: --data '{ "branch": "$CIRCLE_BRANCH" }' , there is no master OR test_branch value but probably $CIRCLE_BRANCH literally. So how to solve that
Richard MacCutchan 27-Sep-20 6:23am    
There is nothing to solve. Look at the code, it accepts one of two parameter values: either "test_branch" or "master".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900