Skip to content

Commit 7b5f0ea

Browse files
committed
adding functionality to give specific version to deploy on initial deploy
1 parent 558b12d commit 7b5f0ea

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

DSCResources/cTentacleAgent/cTentacleAgent.psm1

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function Get-TargetResource
1919
[string]$DefaultApplicationDirectory,
2020
[int]$ListenPort,
2121
[bool]$InitialDeploy,
22-
[string]$DeployProject
22+
[string]$DeployProject,
23+
[string]$DeployVersion
2324
)
2425

2526
Write-Verbose "Checking if Tentacle is installed"
@@ -80,17 +81,18 @@ function Set-TargetResource
8081
[string]$DefaultApplicationDirectory = "$($env:SystemDrive)\Applications",
8182
[int]$ListenPort = 10933,
8283
[bool]$InitialDeploy = $false,
83-
[string]$DeployProject
84+
[string]$DeployProject,
85+
[string]$DeployVersion
8486
)
8587

8688
if ($Ensure -eq "Absent" -and $State -eq "Started")
8789
{
8890
throw "Invalid configuration: service cannot be both 'Absent' and 'Started'"
8991
}
9092

91-
if ( (-not $InitialDeploy) -and $DeployProject)
93+
if ( (-not $InitialDeploy) -and ($DeployProject -or $DeployVersion))
9294
{
93-
throw "Invalid configuration: Resource set to not do initial deploy but Project to deploy to specified"
95+
throw "Invalid configuration: Resource set to not do initial deploy but Project and/or Version to deploy to specified"
9496
}
9597

9698
$currentResource = (Get-TargetResource -Name $Name)
@@ -145,7 +147,14 @@ function Set-TargetResource
145147
}
146148
if ($State -eq "Started" -and $Ensure -eq "Present" -and $InitialDeploy)
147149
{
148-
Invoke-InitialDeploy -name $Name -apiKey $ApiKey -octopusServerUrl $octopusServerUrl -Environments $Environments -Project $DeployProject -Wait
150+
if ($DeployVersion)
151+
{
152+
Invoke-InitialDeploy -name $Name -apiKey $ApiKey -octopusServerUrl $octopusServerUrl -Environments $Environments -Project $DeployProject -Version $DeployVersion -Wait
153+
}
154+
else
155+
{
156+
Invoke-InitialDeploy -name $Name -apiKey $ApiKey -octopusServerUrl $octopusServerUrl -Environments $Environments -Project $DeployProject -Wait
157+
}
149158
}
150159

151160
Write-Verbose "Finished"
@@ -171,7 +180,8 @@ function Test-TargetResource
171180
[string]$DefaultApplicationDirectory,
172181
[int]$ListenPort,
173182
[bool]$InitialDeploy,
174-
[string]$DeployProject
183+
[string]$DeployProject,
184+
[string]$DeployVersion
175185
)
176186

177187
$currentResource = (Get-TargetResource -Name $Name)
@@ -375,6 +385,7 @@ function Invoke-InitialDeploy
375385
[string]$Project,
376386
[Parameter(Mandatory=$True)]
377387
[string[]]$Environments,
388+
[string]$Version = "latest",
378389
[Switch]$Wait = $true
379390
)
380391

@@ -401,7 +412,7 @@ function Invoke-InitialDeploy
401412
foreach ($environment in $environments)
402413
{
403414
Write-Verbose "Deploying Project $Project to environment $environment"
404-
$deployArguments = @("deploy-release", "--project", $Project, "--deployto", $environment, "--releaseNumber", "latest", "--specificmachines", $env:COMPUTERNAME, "--server", $octopusServerUrl, "--apiKey", $apiKey)
415+
$deployArguments = @("deploy-release", "--project", $Project, "--deployto", $environment, "--releaseNumber", $Version, "--specificmachines", $env:COMPUTERNAME, "--server", $octopusServerUrl, "--apiKey", $apiKey)
405416
if ($Wait)
406417
{
407418
$deployArguments += "--waitfordeployment"

DSCResources/cTentacleAgent/cTentacleAgent.schema.mof

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ class cTentacleAgent : OMI_BaseResource
1414

1515
[Write] boolean InitialDeploy;
1616
[Write] string DeployProject;
17+
[Write] string DeployVersion;
1718
};

0 commit comments

Comments
 (0)