Email communications

Is there a way to have an email communication occur outside of several projects? In other words, can we deploy several projects all at once, with an email before and after all deployments have completed?

Hi,

Thanks for reaching out. There’s no built-in way to do this, but you could create an orchestration project that would have powershell steps that use Octo.exe to trigger deployments on several projects at a time. You could add email steps at the beginning and end of this orchestration project’s deployment process.

Thanks,

Dalmiro

Wonderful, can you point me to any good guide or docs on octo.exe?

Hi Conrad,

There you have: http://docs.octopusdeploy.com/pages/viewpage.action?pageId=3048165

Cheers

Dalmiro

Ok I hit another wall

Here is my source script, how can I make it replace those values with octopusparameters?

cmd.exe /c “$OctoExe create-release --project $OctoStepName --deployto $OctoEnv --server http://build1/ --apiKey $APIKey --progress --waitfordeployment”

[cid:image001.png@01D0E599.ADBAC580]

[cid:image002.png@01D0E599.ADBAC580]
Could not find a project named ‘$OctopusParameters[‘Octopus.Step.Name’]’; either it does not exist or you lack permissions to view it.

Hi,

That’s not working because the Project-level variables ($OctoStepName, $OctoEnv) are resolved when the release is created, but the deployment variables (all that start with $OctopusParameters) are resolved during the deployment. So by the time $OctoStepName is created, its value is the string “$OctopusParameters[‘Octopus.Step.Name’]” instead of the actual step name.

You should be able to use the deployment variables when calling Octo.exe like this:

$Octoexe = "C:\Tools\Octo.exe"

& $Octoexe create-release --project $OctopusParameters['Octopus.Step.Name'] --deployto $OctopusParameters['Octopus.Environment.Name'] --server http://build1/ --apiKey $APIKey --progress --waitfordeployment

Hope that helps,

Dalmiro

I tired that suggestion and got a different error:

Executing script on tentacle ‘BUILD1’
09:20:39Info
Octopus Deploy Command Line Tool, version 3.0.18.71
09:20:40Info
Handshaking with Octopus server: http://build1/
09:20:41Info
Handshake successful. Octopus version: 3.0.20.0; API version: 3.0.0
09:20:41Info
Authenticated as: APIUser <> (a service account)
09:20:41Info
Finding project: DSystem.Collections.Generic.Dictionary2[System.String,System.String]['Octopus.Step.Name'] 09:20:42Info Could not find a project named 'DSystem.Collections.Generic.Dictionary2[System.String,System.String][‘Octopus.Step.Name’]’; either it does not exist or you lack permissions to view it.
09:20:42Info
Exit code: -1
09:20:42Error
The remote script failed with exit code -1

My overall goal is create and orchestration project that calls all other projects. All children project just have a single step of deploy nuget package. I can get it to work if I hard code everything in the octo.exe command, but I was hoping to make re usable code.

Hi,

Do you have the variable $OctopusParameters['Octopus.Step.Name'] between double quotes in your script? If that is the case, you need to put is like this: $($OctopusParameters['Octopus.Step.Name'])

Let me know if that helps

Dalmiro

That worked!. Thanks. So it was just a syntax issue? Here is the final working script

cmd.exe /c “$OctoExe create-release --project $($OctopusParameters[‘Octopus.Step.Name’]) --deployto $($OctopusParameters[‘Octopus.Environment.Name’]) --server $OctoURL --apiKey $APIKey --progress --waitfordeployment”

Hi Conrad,

Correct it was a syntax issue. $OctopusParameters is a dictionary, and the correct way to use its values inside of a double-quoted string is by wrapping it between $()

In the attached screenshot I’ve created a dictionary -> added a value to it -> tried to show the value the wrong way -> then the right way

Cheers

Ok I nearly have all the issues worked out with the email comm. How would I call the nuggetpackageId and nuggetpackageVersion programmatically for the child releases? Also how could I only print html in the email if that component was modified? Here is the code I have now for sending the email. For example, I would like to only print StepName1 if it was not skipped. I imagine you will need some more info, so please ask me about anything that is unclear.

[cid:image001.png@01D0F54F.A68C52E0]

Thanks,

Conrad Challenor

Network Operations Administrator

Product Name Product Version
#{Octopus.Action[StepName1].Package.NuGetPackageId} #{Octopus.Action[StepName1].Package.NuGetPackageVersion}
#{Octopus.Action[StepName2].Package.NuGetPackageId} #{Octopus.Action[StepName2].Package.NuGetPackageVersion}
#{Octopus.Action[StepName3].Package.NuGetPackageId} #{Octopus.Action[StepName3].Package.NuGetPackageVersion}

Also, this current setup is creating a new release of the child projects for each environment. Is there a way to create a release on the initial run of the orchestrator project and then call that release for other environments?

Thanks,

Conrad Challenor

Network Operations Administrator

From: Conrad J. Challenor
Sent: Tuesday, September 22, 2015 3:59 PM
To: ‘Dalmiro Grañas’ tender2+deb0c1d91a@tenderapp.com
Subject: RE: Email communications [Questions #5498]

Ok I nearly have all the issues worked out with the email comm. How would I call the nuggetpackageId and nuggetpackageVersion programmatically for the child releases? Also how could I only print html in the email if that component was modified? Here is the code I have now for sending the email. For example, I would like to only print StepName1 if it was not skipped. I imagine you will need some more info, so please ask me about anything that is unclear.

[cid:image001.png@01D0F6A9.DD48DC30]

Thanks,

Conrad Challenor

Network Operations Administrator

Product Name Product Version
#{Octopus.Action[StepName1].Package.NuGetPackageId} #{Octopus.Action[StepName1].Package.NuGetPackageVersion}
#{Octopus.Action[StepName2].Package.NuGetPackageId} #{Octopus.Action[StepName2].Package.NuGetPackageVersion}
#{Octopus.Action[StepName3].Package.NuGetPackageId} #{Octopus.Action[StepName3].Package.NuGetPackageVersion}

Hi Conrad,

You can create and deploy the release for any project/environmnet from a step using Octo.exe create-release http://docs.octopusdeploy.com/display/OD/Creating+releases . Create-release usually just creates the release (and it doesnt deploy it), but if you add the -deployto parameter, it will also deploy it to the environment of your choice.

Hope that helps

Dalmiro