Answers: <p>There are some issues with the way you have implemented your CI workflows:</p>
  <ul>
  <li>It sounds like CodeFresh is attempting to do a build on the branch that is being merged and deleted.  Instead, you should be building on your integration branch (e.g., Develop, master).</li>
  <li>If you choose to adopt a Pull Request workflow, you'll still have this issue if the code is merged and the source branch is deleted before the branch build completes.</li>
  </ul>
  <p>Consider implementing a workflow where you only build a branch if there is a Pull Request and the branch is updated.  Otherwise, stick to compiling just the mainline integration branch.  This will ultimately speed up your CI process as well.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-07-09T21:36:09.890Z
Answers: 2021-07-09T21:36:09.890Z
Answers: Wesley Rolnick
Body: <p>I configured Bitbucket webhook to trigger on Repository push.
  After each merge (which also deletes the source branch) it triggers build, which fails in Codefresh because of deleted branch.</p>
  <p>Does anyone have the same experience?
  How do you deal with it?</p>
  
Comments: CC BY-SA 4.0
Comments: 2021-07-06T08:37:15.680Z
Comments: We usually use 'Pull Request' based bitbucket triggers to our build server, which helps avoid these issues and allows us more control of the CI system.
Comments: Noam Helmer
Comments: CC BY-SA 4.0
Comments: 2021-07-07T21:06:27.587Z
Comments: Even with  'Pull Request' based bitbucket triggers we get failed builds because of deleted branches.
Comments: isobretatel
Comments: CC BY-SA 4.0
Comments: 2021-07-09T14:52:33.483Z
Comments: When you define 'Pull Request' based bitbucket trigger you can control when it will be triggered - you can set it to trigger when a pull request is opened or code was updated, then it wont trigger when a branch was deleted.
Comments: Noam Helmer
Tags: <bitbucket><builds><codefresh>
Title: Bitbucket triggers builds on deleted branches
UserDisplayName: isobretatel
ThreadText: # Bitbucket triggers builds on deleted branches
  
  (Asked by: username_0 on 2021-07-02)
  
  I configured Bitbucket webhook to trigger on Repository push.
  After each merge (which also deletes the source branch) it triggers build, which fails in Codefresh because of deleted branch.
  
  Does anyone have the same experience?
  How do you deal with it?
  
  **Tags:** bitbucket, builds, codefresh
  
  > **Comments:**
  > **username_1**: We usually use 'Pull Request' based bitbucket triggers to our build server, which helps avoid these issues and allows us more control of the CI system.  
  > **username_0**: Even with  'Pull Request' based bitbucket triggers we get failed builds because of deleted branches.  
  > **username_1**: When you define 'Pull Request' based bitbucket trigger you can control when it will be triggered - you can set it to trigger when a pull request is opened or code was updated, then it wont trigger when a branch was deleted.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-07-09. Score: 1
  
  There are some issues with the way you have implemented your CI workflows:
  
  * It sounds like CodeFresh is attempting to do a build on the branch that is being merged and deleted. Instead, you should be building on your integration branch (e.g., Develop, master).
  * If you choose to adopt a Pull Request workflow, you'll still have this issue if the code is merged and the source branch is deleted before the branch build completes.
  
  Consider implementing a workflow where you only build a branch if there is a Pull Request and the branch is updated. Otherwise, stick to compiling just the mainline integration branch. This will ultimately speed up your CI process as well.
  
  
  ---
  
  