Hi Kenny,
I did the changes like you said, but still I am getting error message like below, please find my script as well.
Cannot convert argument ânewItemsâ, with value: âEnvironments-963â, for âReplaceAllâ to type
âSystem.Collections.Generic.IEnumerable1[System.String]": "Cannot convert the "Environments-963" value of type "System.String" to type "System.Collections.Generic.IEnumerable
1[System.String]â."
At C:\Bamboo-Home\xml-data\build-dir\OctoCLI\ProcessStep.ps1:47 char:1
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $octopusURI,$apikey
$repository = New-Object Octopus.Client.OctopusRepository $endpoint
foreach ($pkmn in $pkdex) {
$ProjectId = $($pkmn.ProjectId) # Get this from /api/projects
$StepName = $($pkmn.StepName) # The name of the step
$Role = $($pkmn.Role) # The machine role to run this step on
$PackageId = $($pkmn.PackageId)
#$AccountId = $($pkmn.AccountId)
#$ResourceGroupName = $($pkmn.ResourceGroupName)
#$WebAppName = $($pkmn.WebAppName)
$PhysicalPath = $($pkmn.PhysicalPath)
$TargetFiles = $($pkmn.TargetFiles)
$environment = âGlss-Aquaâ
$project = $repository.Projects.Get($ProjectId)
$process = $repository.DeploymentProcesses.Get($project.DeploymentProcessId)
$environmentToAdd = $repository.Environments.FindByName($environment).Id
$step = New-Object Octopus.Client.Model.DeploymentStepResource
$step.Name = $StepName
$step.Condition = [Octopus.Client.Model.DeploymentStepCondition]::Success
$step.Properties[âOctopus.Action.TargetRolesâ] = $Role
$scriptAction = New-Object Octopus.Client.Model.DeploymentActionResource
$scriptAction.ActionType = âOctopus.AzureWebAppâ
$scriptAction.Name = $StepName
$scriptAction.Properties.Add(âOctopus.Action.Azure.UseChecksumâ, âFalseâ)
$scriptAction.Properties.Add(âOctopus.Action.Package.FeedIdâ, âfeeds-builtinâ)
$scriptAction.Properties.Add(âOctopus.Action.Package.PackageIdâ, â$PackageIdâ)
#$scriptAction.Properties.Add(âOctopus.Action.Azure.AccountIdâ, â$AccountIdâ)
#$scriptAction.Properties.Add(âOctopus.Action.Azure.ResourceGroupNameâ, â$ResourceGroupNameâ)
#$scriptAction.Properties.Add(âOctopus.Action.Azure.WebAppNameâ, â$WebAppNameâ)
$scriptAction.Properties.Add(âOctopus.Action.Azure.PhysicalPathâ, â$PhysicalPathâ)
$scriptAction.Properties.Add(âOctopus.Action.SubstituteInFiles.Enabledâ, âTrueâ)
$scriptAction.Properties.Add(âOctopus.Action.EnabledFeaturesâ, âOctopus.Features.SubstituteInFilesâ)
$scriptAction.Properties.Add(âOctopus.Action.SubstituteInFiles.TargetFilesâ, â$TargetFilesâ)
$scriptAction.Properties.Add(âOctopus.Action.Package.DownloadOnTentacleâ, âFalseâ)
$scriptAction.Environments.ReplaceAll($environmentToAdd)
$step.Actions.Add($scriptAction)
$process.Steps.Add($step)
$repository.DeploymentProcesses.Modify($process)
}
Regards,
Satish