# Run Stage on all relevant agents

**URL:** https://www.finalbuilder.com/forums/t/run-stage-on-all-relevant-agents/7071
**Category:** Discussion
**Created:** [July 2, 2021, 1:44am UTC](https://www.finalbuilder.com/forums/t/run-stage-on-all-relevant-agents/7071 "2021-07-02T01:44:07Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![fastbike](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/f/9dc877/32.png) [@fastbike](https://www.finalbuilder.com/forums/u/fastbike)
#### Post date: [July 2, 2021, 1:44am UTC](https://www.finalbuilder.com/forums/t/run-stage-on-all-relevant-agents/7071/1 "2021-07-02T01:44:07Z")

</div>

We now are using Continua to do our releases, having previously just used it to do the build and deploy to the test environment.

We have two UAT and two Production servers, so we will install the agent onto each of these 4 servers.

The release script calls a Powershell script that makes a zipped archive of the current server artifacts.

How do we get Continua to run this script on all 4 agents, rather than just the first available, and to pause execution until the stage has completed ?

---

<div class="post-metadata">

### Author: ![fastbike](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/f/9dc877/32.png) [@fastbike](https://www.finalbuilder.com/forums/u/fastbike)
#### Post date: [July 2, 2021, 1:53am UTC](https://www.finalbuilder.com/forums/t/run-stage-on-all-relevant-agents/7071/2 "2021-07-02T01:53:15Z")

</div>

I can see a “workaround” but not sure if this is very scalable.  
If I create a stage and add the stage requirement to be an agent property that is different for each of the 4 servers, and then clone that stage to get 4 stages where each has a stage requirement corresponding to one of the four server agent properties then it would run through each of those 4 stages.

A bit messy and a pain if we add new servers.

I’m still after a better way of getting this to work

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [July 2, 2021, 3:32am UTC](https://www.finalbuilder.com/forums/t/run-stage-on-all-relevant-agents/7071/3 "2021-07-02T03:32:47Z")

</div>

Hi David,

The “workaround” solution that you propose is one that we use on our own build server to update tools on our agents. This works fine, but as you say, it does require some additional configuration when a new agent is added (or removed). Installing a new agent generally requires plenty of configuration tasks anyway.

We don’t currently have a way to run one stage on more than one agent, although this is something that we would like to implement in the future. Unfortunately, it’s not a quick feature that we can put together in the short term.

Another solution would be to start the script from a single agent and use [Powershell remoting](https://devops-collective-inc.gitbook.io/secrets-of-powershell-remoting/remoting-basics) to execute it on each server. This involves sending the `-ComputerName` and also credentials as parameters to the PowerShell action - see [Using saved credentials securely in PowerShell scripts](https://purple.telstra.com.au/blog/using-saved-credentials-securely-in-powershell-scripts). The PowerShell actions in Continua CI and FinalBuilder do currently allow you to specify any parameters so this should be achievable without any updates. We do however plan to update the actions with new fields to make it easier to specify the parameters required for remoting.

The PowerShell action could be iterated for each server using the For Each action in Continua CI.

Alternatively, you could make use of our [Octopus Deploy build event handler](https://wiki.finalbuilder.com/display/continua/Octopus+Deploy) to start an Octopus Deploy deployment to run the Powershell scripts at the end of a stage or the build.

---

<div class="post-metadata">

### Author: ![k3tchup](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/k3tchup/32/2162_2.png) [@k3tchup](https://www.finalbuilder.com/forums/u/k3tchup)
#### Post date: [July 5, 2021, 3:18pm UTC](https://www.finalbuilder.com/forums/t/run-stage-on-all-relevant-agents/7071/4 "2021-07-05T15:18:05Z")

</div>

I type an entire description of a simpler solution but it disappeared on Reply…  
If you are interested in details let me know, I will write it again.

The idea is for the build to trigger itself and store agent hostnames to build variable, then agent requirements base on that variable and skip already processed agents.  
I tested it and it works.

It has one caveat tho, meaning end condition in pure Continua may not work properly as Continua has no list variables and operators.

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [July 6, 2021, 1:26am UTC](https://www.finalbuilder.com/forums/t/run-stage-on-all-relevant-agents/7071/5 "2021-07-06T01:26:09Z")

</div>

That’s a great idea Michal.

A Build Completed trigger can be used to recursively trigger the same build. Continua CI does have some list functionality which, although limited, can be used to achieve this.

- First set up a Text variable “AgentList” containing a list of the agent host names. e.g. `"agent1","agent2","agent3"`. You can use a Checkbox Select prompt type here if you want to allow users to select which agents to run on.

- Then create a Numeric variable “AgentIndex” initialised to “0”.

- Add a Build Completed Trigger.

- In your stage Agent Requirements, add the expression `[$Agent.Hostname$] [Equals] [$Utils.GetString(%AgentList%).SplitWithQuotes(",","double",true).Item(%AgentIndex%)$]`

---

<div class="post-metadata">

### Author: ![k3tchup](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/k3tchup/32/2162_2.png) [@k3tchup](https://www.finalbuilder.com/forums/u/k3tchup)
#### Post date: [July 6, 2021, 2:08pm UTC](https://www.finalbuilder.com/forums/t/run-stage-on-all-relevant-agents/7071/6 "2021-07-06T14:08:56Z")

</div>

> [@Sparky](#):
>
> [$Utils.GetString(%AgentList%).SplitWithQuotes(“,”,“double”,true).Item(%AgentIndex%)$]

Didn’t know about that 🙂  
This fixes the caveat.

Is there any documentation for those functions ?  
What does “double” stand for ?

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [July 6, 2021, 11:22pm UTC](https://www.finalbuilder.com/forums/t/run-stage-on-all-relevant-agents/7071/7 "2021-07-06T23:22:55Z")

</div>

> [@k3tchup](#):
>
> Is there any documentation for those functions ?

Yes: [String Object - Continua CI - VSoft Technologies Documentation Wiki (finalbuilder.com)](https://wiki.finalbuilder.com/display/continua/String+Object)

> [@k3tchup](#):
>
> What does “double” stand for ?

Double quotes

---

<div class="post-metadata">

### Author: ![fastbike](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/f/9dc877/32.png) [@fastbike](https://www.finalbuilder.com/forums/u/fastbike)
#### Post date: [March 25, 2022, 12:28am UTC](https://www.finalbuilder.com/forums/t/run-stage-on-all-relevant-agents/7071/8 "2022-03-25T00:28:47Z")

</div>

Just circling back onto this issue as it is biting us as we move to more servers. I stumbled onto this blog post from 7 years ago …  
[https://www.finalbuilder.com/resources/blogs/deployment-with-continua-ci-and-octopus-deploy](https://www.finalbuilder.com/resources/blogs/deployment-with-continua-ci-and-octopus-deploy)

So I think we need to use the right tool for the job, and use Continua to do the build, and orchestrate the deployment through our various environments with something like Octopus.

Continua can call Octo jobs, so that is a good place to start from  
[https://wiki.finalbuilder.com/display/continua/Octo+Actions](https://wiki.finalbuilder.com/display/continua/Octo+Actions)

Does this support applications compiled from Delphi code ?

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [March 25, 2022, 4:13am UTC](https://www.finalbuilder.com/forums/t/run-stage-on-all-relevant-agents/7071/9 "2022-03-25T04:13:49Z")

</div>

Hi David,

Yes, you can deploy Delphi applications using the Octopus Deploy integration in Continua CI. The executable files can be packaged as a zip file which can then be extracted and deployed using various steps in the Octopus Deploy process.

In your Continua CI build configuration, after the normal build actions, you’ll need to [create a Zip package](https://octopus.com/docs/packaging-applications/create-packages/octopus-cli) containing all the build output files that you wish to deploy. You can use the [Octo Pack Action](https://wiki.finalbuilder.com/display/continua/Octo+Pack+Action) for this.

Next you’ll need to [push the package](https://octopus.com/docs/packaging-applications/package-repositories/built-in-repository#UsingOctopusCli) to the built-in repository on your Octopus Deploy server. You can use the [Octo Push Action](https://wiki.finalbuilder.com/display/continua/Octo+Push+Action) for this.

On your Octopus Deploy server, create a [deployment project](https://octopus.com/docs/projects). This will need to contain all the steps required to extract the files from the zip package, copy them to the required locations and configure the application.

Then, go back to your Continua CI configuration, and add an [Octopus Deploy build event handler](https://wiki.finalbuilder.com/display/continua/Octopus+Deploy). This can be used to create a deployment on the Octopus Deploy server for a specific project (usually at the start of the build) and then run the deployment release at the end of the build (once the package has been uploaded).

The blog post you referred to is old, as you say, but still very much applicable to deploying .Net applications built using MSBuild. We plan to write a new blog post describing the process for deploying a Delphi application in more detail in due course.
