How to do a build/create a build plan in bamboo for various environment like int, dev and prod?
Asked by Aakash Basnet:

we have got three development environment i,e int, dev and prod. how to do a build and setup continuous integration for different environment? shall we have to configure a different plan with different task or can we do with the same plan and task? please provide me the answer from basic along with overview concept?

Thank you very much in advance


Answers:
author: Juan Peraza
body: In response to your question about labeling each build by date and time stamp, this documentation [page](https://confluence.atlassian.com/display/BAMBOO057/Bamboo+variables#Bamboovariables-Build-specificvariables) lists the Bamboo variables. Looks like there is a build-specific variable bamboo.buildTimeStamp that contains the time when a build was started in ISO 8601 format e.g. 2010-01-01T01:00:00.000+01:00

comments: author: Aakash Basnet
body: Thanks Juan,Really you are helping me a lot.one more question for you, As you said that you have a single build plan that linked with single repos and you have a separate deployment environment and you also said that your artifacts are named according to the target deploy environment. like application-test.zip. Now My question is: From one build plan you always get the same artifact doesn't matter what ever you named it, If so how does it make sense that feeding the same type of artifact to different deployment environment? Or how do you create a different artifact for different environment?Please correct me If I am wrong in some way.Your feed back will be highly appreciated.


author: Juan Peraza
body: The job in the build plan that compiles and packages the application, has separate msbuild tasks to create artifacts for each deployment environment. So the job has a task to execute msbuild with arguments /p:Configuration="dev";PackageLocation="dev.zip", a task to execute msbuild with arguments /p:Configuration="test";PackageLocation="test.zip", and a task to execute msbuild with arguments /p:Configuration="prod";PackageLocation="prod.zip". The 3 differently-named zip file are 3 different artifacts that I can reference individually when deploying to separate dev, test, and production environments. The artifacts are shared artifacts in the compile job of my build plan. Because they are shared artifacts, my deployment project that is tied to my build plan can have access to them to deploy them. My deployment project has 3 separate environments defined. In each environment, I specify the tasks to execute to deploy the application to that environment. One of the tasks I execute during deployment is the Artifact download task. In this task you specify the specific artifacts from the build plan to deploy to the specific target environment. For my Dev deployment environment, I deploy the dev.zip file, for the Test deployment environment, I deploy the test.zip file, ... Hope that helps.


author: Aakash Basnet
body: Thank you very much and sorry for bothering you again and again.Do you mean to say that you have three different tasks under stages \& jobs defined for different environment and they are linked with same repository right? Does that three jobs runs in parallel? Since these task have same configuration and they are using the same same code from single repositories, how does the 3 different named artifacts different from each other? It seems that still I have some confusion or missing something important.I am using maven task and shared the artifact for deployment, but still not clear how to create three different artifact for different environment?Please If possible attach with the screenshot explain also.Your feedback will be highly appreciated..


author: Aakash Basnet
body: Hi [Juan Peraza](https://answers.atlassian.com/questions/users?username=juan%20peraza)

How do I deploy my application to web logic server.I didn't find the task of deploy to Web logic server in Bamboo deployment task like tomcat server?

comments: author: Juan Peraza
body: I have no experience deploying to WebLogic. I suggest posting a separate question to Atlassian Answers specific to deploying to WebLogic from Bamboo.


author: Juan Peraza
body: To copy an existing plan, select *Clone an existing plan* from the Create button.


author: Aakash Basnet
body: I think we can use a "create branch plan" option to Create plan branches for branches detected in the repository .If you use this option your build will run against each branch.

How to copy the build plan?


author: Aakash Basnet
body: Awesome!!

Why do you have different build plan for every branch detected in Git? Is that because you want to run a build against each branch? or is there any specific reason for this?

what about the job/task? do you create a different task for each build plan? or use same task for all plan?

comments: author: Juan Peraza
body: Yes, I have a different build plan per branch because I build each branch. I'm sure there's a way to have a single build plan and be able to feed it a branch as an argument, but I only have 2 to 3 branches at a time, so I like having a separate plan per branch. As for the job/tasks per build plan, I copied my original build plan (Bamboo has that feature) to create other build plans as I needed them. So the same job/tasks for all plans with slight diffs - like the source repository setting for each plan.


author: Juan Peraza
body: Correct, I have a separate build plan for each branch.

To define/create artifacts, yes, I use the Create definition button on the Artifacts definition page. I have such few artifacts, that I name them explicitly instead of using some type of pattern. We don't use (nor have a need for) a remote repository to store our artifacts. I would if I had to share the artifacts among different applications. However, all my artifacts are specific to a single application. I wonder if you can execute some maven command during your build to store the artifacts in nexus. I used maven 2 years ago, and have forgotten details about it and nexus, so I can't help much regarding that. The reason I don't have to store artifacts for my single application is because my Bamboo agent which handles the deployments (this is a different Bamboo agent than the one that I build with) can access the artifacts from the build since the artifacts from the build are shared. Therefore no need in my case for nexus or similar.


author: Aakash Basnet
body: Great!!

So you have a different build plan for different branch that pertains in Git.That mean you have separate build plan for each branch?

Finally Do you named the artifact by create definition option or other way? and How can we save or point the artifact to the remote repository like nexus?


author: Juan Peraza
body: How do I differentiate particular artifacts for separate environments? **Answer:** My artifacts are named according to the target deploy environment. i.e. application-test.zip, application-prod.zip. Some of the artifacts are common across deploy environments.

How do I label my build? **Answer:** I create a label associated with a job that does the compilation. The label can be defined by clicking on the job, then clicking on the Miscellaneous tab. Each build has a label defined by ${bamboo.buildKey}${bamboo.buildNumber}.

As for triggering the build, we don't follow the git flow. I have a single project in Bamboo for an application, then that project has 1 to 3 build plans. Each build plan pertains to a branch in Git. The build plans are triggered using the Repository polling trigger. We only build automatically once a day - overnight. So far our projects are single-developer projects, so no dire need for true *continuous* integration build. Daily (overnight) integration builds are sufficient.

comments: author: Aakash Basnet
body: Hi Juan,Need your help again. Regarding automatic Labeling,lets say I want to label by build with latest date and time stamp.In Miscellaneous tab there is two field Regex pattern and labelling but I am not sure what to include in those fields.So kindly request you for the suggestions


author: Aakash Basnet
body: Thank you very much for your informative answer

Since you have a same build plan how do you differentiate the particular artifact for separate environment?

Also how do you label your build?

Another quick question please?

We are going to follow git flow branching workflow. my question is what is best way to trigger the build? like build against feature branch/develop/release or master. How to configure a build plan for git flow branching model?


author: Juan Peraza
body: Here's what I did. I have a single build plan. That build plan generates shared artifacts. I also have a deployment project which is linked to my build plan. The deployment project has separate environments defined that you can deploy to. Because my deployment project is linked to a build plan, I can specify what artifacts from the build plan's shared artifacts to deploy. My deployment to prod is manual (you push a button in Bamboo to make it happen), and my deployments to int and dev are triggered to automatically happen whenever there is a successful build in my build plan. So that's my high level description. If this might apply to you, then I can share more details.