One deployment plan or one deployment environment for multiple build plans
Asked by Aleksandr Sorokin:

I have multiple build plans for a variety of repos.

I want to use one deployment project and one environment for all of them

I've read this

<https://community.atlassian.com/t5/Bamboo-questions/How-can-I-reference-multiple-build-plans-in-deployment-project/qaq-p/60451>

However, when i tried this solution i bumped into the problem - no variables sharing between child plans. Also i should set up certain build plan for artifact download in child plan. So.. For me where is no solution


Answers:
author: Foong
body: > no variables sharing between child plans.

Save the variable in the first child plan into a file and set it as artifact. The second plan can download the artifact and use "Inject Bamboo variable" task to create the variable from first plan.

comments: author: Aleksandr Sorokin
body: you should specify certain plan from which artefacts could be downloaded (correct for version 6.6.1). As a result, you can't use this trick for multiple plans.

![bamboo.png](https://community.atlassian.com/t5/image/serverpage/image-id/47016i9ABB674858CEB14D/image-size/large?v=v2&px=999 "bamboo.png")


author: Foong
body: Can you clarify more on the reason?

Do you mean that child plan B could not download artifact from child plan A?


author: Aleksandr Sorokin
body: ![bamboo2.png](https://community.atlassian.com/t5/image/serverpage/image-id/47018iAC01A72D4851947B/image-size/large?v=v2&px=999 "bamboo2.png")


author: Aleksandr Sorokin
body: Plan A independent from Plan B.


author: Foong
body: Plan pipe could not download Artifact from Plan A and B?


author: Aleksandr Sorokin
body: I need solution with one deployment project, so i can get one deployment environment.


author: Foong
body: Yes, Plan pipe should be able to download artifact from plan A and B. Then, generate artifacts again so that it can be downloaded in deployment environment.

Which part of it is not working?


author: Aleksandr Sorokin
body: 1. Plan A and Plan B builds independently. It is not a real problem in this case

2. Whose artefact I would get in Plan Pipe if I included tasks

a. Download artifacts from Plan B

b. Download artifacts from Plan A

c. inject variables from file


author: Foong
body: If there are two Artifact Download tasks, Plan Pipe can download artifacts from both Plan A and Plan B.

Inject variable task is used to create variable from file. If Plan A and B variables are saved in file and set to be artifact, Plan Pipe can create variables from Plan A and B into Plan Pipe.


author: Aleksandr Sorokin
body: Whose artefact file with variables I would get?

Could you tell me if where limit on tasks in one plan in case we have 200 plans

So it will looks like

1. Download Artefacts from Plan A

2. Download Artefacts from Plan B

3. Download Artefacts from Plan C

...

100. Download Artefacts from Plan FAA

101. Download Artefacts from Plan FAB

...

200. Inject variables from file "variables"


author: Foong
body: There is no limit in task. If there are 200 plans, it would be better to group it in different Plan Pipe, for example:

Plan Pipe A will download from Plan A-Z

Plan Pipe B will download from Plan BA-BZ

...

Final Plan Pipe will download from Plan Pipe A, Plan Pipe B, ...

Inject variable task is used to create variable from file.

If Plan A save the important variable in a file A and Plan B save the important variable in a file B, the final Plan Pipe can use Script task to combine the data from file A and file B into a single file first before using the Inject variable task.


author: Aleksandr Sorokin
body: Can we determine in child plan which plan triggered pipe plan?

For me it looks if we cant save variable in same file, in case it would be replaced by latest artefact downloading task, we should use script to choose the file which would be injected.


author: Foong
body: > Can we determine in child plan which plan triggered pipe plan?

Do you mean if Bamboo will show which child plan trigger pipe plan or you want to control which child plan should trigger pipe plan?

Plan A is configured as the parent (dependency setting) of Plan Pipe so that after Plan A finish running, it will trigger Plan Pipe. Plan Pipe will show that it has been trigger by Plan A.

[Setting up plan build dependencies](https://confluence.atlassian.com/bamboo/setting-up-plan-build-dependencies-289276887.html)
> For me it looks if we cant save variable in same file, in case it would be replaced by latest artefact downloading task, we should use script to choose the file which would be injected.

You have to use a Script task to save the variable from Plan A into a file which mean you can decide which variable to save inside Plan A.


author: Aleksandr Sorokin
body: ```
Do you mean if Bamboo will show which child plan trigger pipe plan
```

I mean we should somehow determine from which plan i should inject variables.

I dont need all plans variables i need plan which triggered pipe plan and only its variables.


author: Foong
body: You can use a Script task in a single Plan to save its variable so that it can be shared to the pipe plan then


author: Aleksandr Sorokin
body: I get it but from which plan i should inject variables

Problem stay in pipe plan to determine whose variables i should inject.


author: Foong
body: For example:

Plan A - use a Script task to save the variable into a file A. File A is set to be Artifact

Plan B - no need save variable so no extra Script task created to save it

Plan C - no need save variable so no extra Script task created to save it

...

Plan Pipe download Artifact File A from Plan A

Plan Pipe use Inject variable task to read from File A to create variable. The Inject variable task can be configured to read data from File A only.


author: Aleksandr Sorokin
body: In my case

Plan A - use a Script task to save the variable into a file A. File A is set to be Artifact

Plan B - use a Script task to save the variable into a file B. File B is set to be Artifact

Plan C - use a Script task to save the variable into a file C. File C is set to be Artifact

...

Plan ABC - use a Script task to save the variable into a file ABC. File ABC is set to be Artifact

---------------------

some of this plans triggered Plan Pipe

----------------------

Plan Pipe download Artifact File A from Plan A

Plan Pipe download Artifact File B from Plan B

Plan Pipe download Artifact File C from Plan C

...

Plan Pipe download Artifact File ABC from Plan ABC

..

Plan Pipe use Inject variable task to read from File ???


author: Foong
body: Inject variable task can be configured to read from a specific file name only. Since each plan have different file name, you can choose which file to be used.


author: Aleksandr Sorokin
body: How we could determine which plan triggered pipe plan.

Is where some variable in Pipe Plan which contain a triggering plan name?


author: Foong
body: If the dependency setting is used to trigger Pipe Plan, the variable ${bamboo.DependencyTriggerReason.triggeringBuildResultKey} will show the related build that trigger it


author: Aleksandr Sorokin
body: Thanks, i will try work around with ${bamboo.DependencyTriggerReason.triggeringBuildResultKey} key.


Tags: build