Bamboo build tying to undesired BitBucket Commit - bitbucket

Context
I have a BitBucket repo and a Bamboo Plan. The Bamboo Plan is tied to the Bitbucket repo in the "Repository" settings.
The Bamboo Plan "Branch" settings are set to create a new Branch when a new branch is created in the repo.
Issue
When I create a branch, bamboo makes a new branch and starts the build. The first build is tied to the latest commit which came from the original branch. I don't want to associate the new branch build with a commit to the original branch. (It causes more than one build to be associated with the commit.)
Desired Outcome
The build should only tie to new commits in the branch.
Solutions
Pull Request Trigger
I modified my bamboo plan to only trigger new bamboo branches when a Pull Request is created for the repo branch. It did give me the desired outcome. The downside is that commits to the branch will not be executed against the CICD process until a PR is created.
Is there a way to create Bamboo branches only on the first commit to a new repo branch?

No.
I'm sorry there isn't much you can do about this.

Related

When Multibranch pipeline when job is trigged, what is stored in Jenkins workspace?

I am not sure if I am asking the question in right way.
When I am triggering the multi branch pipeline job and I do "checkout scm" in Jenkinsfile, does it checkout the pull request or Master + pull request?
It depends of your settings.
As I remember, multibranch pipeline builds pull requests in separated view and it can build as PR source branch and result of PR. It cloned your repo, checkouts target branch, merges source branch into it and runs your stages.
If you look at the logs you will see that it checks out the hash of the commit
example: git checkout 1fb651dfdcbea276627de0247bbf5047840cae4c
As for workspace, if you log in to the Jenkins machine where this is running you will see that each branch has a separated workspace. Here you will find the source code of the checked out branch. The separated workspace ensures that there is no conflict when working with multiple concurrent branch builds.

how do I create Master + PR branch and run some tests on it?

I am new to jenkins.
I want to build pipeline/jenkins job where once developer has pull request approved by other developers with 1 LGTM, I would build a new Master + the PR as new Master and run smoke tests.
If it passes, I will merge to the Master.
Thanks in advance!
You would need to setup a multibranch pipeline on a dedicate repo.
That dedicated repo would be one where (master+PR) branches are pushed to: their new branch would trigger the multibranch pipeline.
In order to push such branches (master+PR), you need another job which will:
periodically fetch from the origina repo
check for any PR branch with a +1 LGTM
create a new branch from master and merge that PR branch
push the resulting new branch to the dedicated remote repo mentioned before.

How to auto-Merge Bitbucket branches from Bamboo?

We are working on a POC with Bamboo and Bitbucket to do an auto-merge between the Master and Feature branches.
The task list is as follows:
Commit code in trunk
Get a repository polled bamboo build for the Trunk
Code gets Auto-merge in feature branch
Get a repository polled bamboo build for the Feature
I am able to do the first two steps but the next two are coming through.
What can be the configuration issue in this plan?
Thanks
You can establish automerging from your Bamboo plan.
Go to Plan Configuration -> Merging -> Branch merging enabled and you have 2 options:
Branch updater
Gatekeeper
For your user case you can use Branch updater, selecting the merged from the branch that you want and pushing on the branch that you want.

Bamboo plan is not starting with Bitucket commit

I have bamboo set up with the testing branch of my Bitbucket repository, and I have set the build plan to trigger when new commits are pushed. Also linked bamboo from Bitbucket as a sevice and link.
Service Link
The problem is that when I push code to testing branch, it won't trigger the build plan. Is there any other thing to do?

How to build the new branch pushed to github using Jenkins CI?

I've setup the Jenkins for the rails3 app to build the specs.
One can find many posts via google on how to setup the build trigger on the github push.
But what I want is to build the new remote branch pushed to Github.
e.g.
I've a repo origin/master. I cloned the repo, created a new branch, did some commits and pushed that branch to origin git push -u origin new_branch
Now I want the Jenkins to build this newly pushed branch on the origin.
If the build is successful, then Jenkins should merge it into origin/master automatically.
The Jenkins plugin has github, git plugin. But it requires to put the branch name. Instead I want to build the new_branch dynamically.
How can I setup such process?
If I remember correctly branch name is not a required entry. You need to test it, but I think if you do not fill it, Jenkins tests all new commit in the repo regardless which branch is affected.
But I recommend you do not merge automatically. You do not want that, trust me. :-)
It seems can not do that with only github and gitgub parameter plugin. If you specify branch_regex*** in Branch to build, Jenkins always build the latest commit in the bunch of branches that it saw. Must specify a branch in order Jenkins to build on the latest commit in that branch. I also see some answer with Multi Branch Pipeline but not sure how to deploy that way. There is no specific instruction at all.

Resources