0

Is it possible to create the repository and post service in one request. Here's what I currently have. I'm worried that the 2nd call might happen before the 1st is finished and fail.

curl -u$BB_USER:$BB_PASS -X POST https://api.bitbucket.org/1.0/repositories/ -d "name=$PROJECT_NAME" -d "owner=$BB_Owner" -d 'is_private=1' -d 'scm=git'
curl -u$BB_USER:$BB_PASS -X POST https://api.bitbucket.org/1.0/repositories/$BB_Owner/$PROJECT_FOLDER/services -d type=POST -d URL=$POST_HOOK_URL
drrobotnik
  • 739
  • 1
  • 11
  • 25

1 Answers1

1

Chain them with '&&' so that the second command executes only if the first command completed successfully.

curl -u$BB_USER:$BB_PASS -X POST https://api.bitbucket.org/1.0/repositories/ -d "name=$PROJECT_NAME" -d "owner=$BB_Owner" -d 'is_private=1' -d 'scm=git' && curl -u$BB_USER:$BB_PASS -X POST https://api.bitbucket.org/1.0/repositories/$BB_Owner/$PROJECT_FOLDER/services -d type=POST -d URL=$POST_HOOK_URL
ptierno
  • 9,534
  • 2
  • 23
  • 35