diff --git a/CloneSpace.ps1 b/CloneSpace.ps1 index 95f0072..91ef3fd 100644 --- a/CloneSpace.ps1 +++ b/CloneSpace.ps1 @@ -34,10 +34,10 @@ param ( $CloneTeamUserRoleScoping, $CloneProjectChannelRules, $CloneProjectVersioningReleaseCreationSettings, - $CloneProjectDeploymentProcess, - $IgnoreVersionCheckResult, - $SkipPausingWhenIgnoringVersionCheckResult, - $CloneTenantVariables, + $CloneProjectDeploymentProcess, + $CloneProjectLogos, + $CloneTenantLogos, + $CloneTenantVariables, $ProcessEnvironmentScopingMatch, $ProcessChannelScopingMatch, $ProcessTenantTagScopingMatch, @@ -53,6 +53,8 @@ param ( $InfrastructureTenantScopingMatch, $InfrastructureTenantTagScopingMatch, $ProcessCloningOption, + $IgnoreVersionCheckResult, + $SkipPausingWhenIgnoringVersionCheckResult, $WhatIf ) @@ -107,7 +109,9 @@ $CloneProjectRunbooks = Test-OctopusTrueFalseParameter -parameterValue $ClonePro $CloneTeamUserRoleScoping = Test-OctopusTrueFalseParameter -parameterValue $CloneTeamUserRoleScoping -parameterName "CloneTeamUserRoleScoping" -defaultValue $false $CloneProjectChannelRules = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectChannelRules -parameterName "CloneProjectChannelRules" -defaultValue $false $CloneProjectVersioningReleaseCreationSettings = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectVersioningReleaseCreationSettings -parameterName "CloneProjectVersioningReleaseCreationSettings" -defaultValue $false -$CloneProjectDeploymentProcess = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectDeploymentProcess -parameterName "CloneProjectDeploymentProcess" -defaultValue $false +$CloneProjectDeploymentProcess = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectDeploymentProcess -parameterName "CloneProjectDeploymentProcess" -defaultValue $true +$CloneProjectLogos = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectLogos -parameterName "CloneProjectLogos" -defaultValue $true +$CloneTenantLogos = Test-OctopusTrueFalseParameter -parameterValue $CloneTenantLogos -parameterName "CloneTenantLogos" -defaultValue $true $CloneTenantVariables = Test-OctopusTrueFalseParameter -parameterValue $CloneTenantVariables -parameterName "CloneTenantVariables" -defaultValue $false $RunbooksToClone = Test-OctopusNewListParameter -parameterValue $RunbooksToClone -parameterName "RunbooksToClone" @@ -172,7 +176,9 @@ $CloneScriptOptions = @{ CloneProjectChannelRules = $CloneProjectChannelRules; CloneProjectVersioningReleaseCreationSettings = $CloneProjectVersioningReleaseCreationSettings; CloneProjectDeploymentProcess = $CloneProjectDeploymentProcess; - CloneTenantVariables = $CloneTenantVariables; + CloneTenantVariables = $CloneTenantVariables; + CloneTenantLogos = $CloneTenantLogos; + CloneProjectLogos = $CloneProjectLogos; ProcessEnvironmentScopingMatch = $ProcessEnvironmentScopingMatch; ProcessChannelScopingMatch = $ProcessChannelScopingMatch; ProcessTenantTagScopingMatch = $ProcessTenantTagScopingMatch; diff --git a/CloneSpaceProject.ps1 b/CloneSpaceProject.ps1 index 43e18d9..d50c07e 100644 --- a/CloneSpaceProject.ps1 +++ b/CloneSpaceProject.ps1 @@ -24,7 +24,9 @@ param ( $CloneTeamUserRoleScoping, $CloneProjectChannelRules, $CloneProjectVersioningReleaseCreationSettings, - $CloneProjectDeploymentProcess, + $CloneProjectDeploymentProcess, + $CloneProjectLogos, + $CloneTenantLogos, $CloneTenantVariables, $ClonePackages, $ProcessEnvironmentScopingMatch, @@ -67,7 +69,9 @@ $CloneProjectRunbooks = Test-OctopusTrueFalseParameter -parameterValue $ClonePro $CloneTeamUserRoleScoping = Test-OctopusTrueFalseParameter -parameterValue $CloneTeamUserRoleScoping -parameterName "CloneTeamUserRoleScoping" -defaultValue $false $CloneProjectChannelRules = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectChannelRules -parameterName "CloneProjectChannelRules" -defaultValue $false $CloneProjectVersioningReleaseCreationSettings = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectVersioningReleaseCreationSettings -parameterName "CloneProjectVersioningReleaseCreationSettings" -defaultValue $false -$CloneProjectDeploymentProcess = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectDeploymentProcess -parameterName "CloneProjectDeploymentProcess" -defaultValue $false +$CloneProjectDeploymentProcess = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectDeploymentProcess -parameterName "CloneProjectDeploymentProcess" -defaultValue $true +$CloneProjectLogos = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectLogos -parameterName "CloneProjectLogos" -defaultValue $true +$CloneTenantLogos = Test-OctopusTrueFalseParameter -parameterValue $CloneTenantLogos -parameterName "CloneTenantLogos" -defaultValue $true $CloneTenantVariables = Test-OctopusTrueFalseParameter -parameterValue $CloneTenantVariables -parameterName "CloneTenantVariables" -defaultValue $false $ClonePackages = Test-OctopusTrueFalseParameter -parameterValue $ClonePackages -parameterName "ClonePackages" -defaultValue $false @@ -692,6 +696,8 @@ Write-OctopusSuccess " -CloneProjectChannelRules $CloneProjectChannelRules" Write-OctopusSuccess " -CloneProjectRunbooks $CloneProjectRunbooks" Write-OctopusSuccess " -CloneProjectVersioningReleaseCreationSettings $CloneProjectVersioningReleaseCreationSettings" Write-OctopusSuccess " -CloneProjectDeploymentProcess $CloneProjectDeploymentProcess" +Write-OctopusSuccess " -CloneProjectLogos $CloneProjectLogos" +Write-OctopusSuccess " -CloneTenantLogos $CloneTenantLogos" Write-OctopusSuccess " -IgnoreVersionCheckResult $IgnoreVersionCheckResult" Write-OctopusSuccess " -SkipPausingWhenIgnoringVersionCheckResult $SkipPausingWhenIgnoringVersionCheckResult" Write-OctopusSuccess " -CloneTenantVariables $CloneTenantVariables" @@ -745,6 +751,8 @@ $cloneSpaceScript = "$PSScriptRoot\CloneSpace.ps1" -CloneProjectRunbooks "$CloneProjectRunbooks" ` -CloneProjectVersioningReleaseCreationSettings "$CloneProjectVersioningReleaseCreationSettings" ` -CloneProjectDeploymentProcess "$CloneProjectDeploymentProcess" ` + -CloneProjectLogos "$CloneProjectLogos" ` + -CloneTenantLogos "$CloneTenantLogos" ` -IgnoreVersionCheckResult "$IgnoreVersionCheckResult" ` -SkipPausingWhenIgnoringVersionCheckResult "$SkipPausingWhenIgnoringVersionCheckResult" ` -CloneTenantVariables "$CloneTenantVariables" ` diff --git a/ProjectSyncer.ps1 b/ProjectSyncer.ps1 index 8e645e0..96b2727 100644 --- a/ProjectSyncer.ps1 +++ b/ProjectSyncer.ps1 @@ -10,6 +10,7 @@ param ( $CloneProjectChannelRules, $CloneProjectVersioningReleaseCreationSettings, $CloneProjectDeploymentProcess, + $CloneProjectLogos, $ProcessEnvironmentScopingMatch, $ProcessChannelScopingMatch, $ProcessTenantTagScopingMatch, @@ -55,7 +56,8 @@ $OverwriteExistingVariables = Test-OctopusOverwriteExistingVariablesParameter -p $CloneProjectRunbooks = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectRunbooks -parameterName "CloneProjectRunbooks" -defaultValue $true $CloneProjectChannelRules = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectChannelRules -parameterName "CloneProjectChannelRules" -defaultValue $false $CloneProjectVersioningReleaseCreationSettings = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectVersioningReleaseCreationSettings -parameterName "CloneProjectVersioningReleaseCreationSettings" -defaultValue $false -$CloneProjectDeploymentProcess = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectDeploymentProcess -parameterName "CloneProjectDeploymentProcess" -defaultValue $false +$CloneProjectDeploymentProcess = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectDeploymentProcess -parameterName "CloneProjectDeploymentProcess" -defaultValue $true +$CloneProjectLogos = Test-OctopusTrueFalseParameter -parameterValue $CloneProjectLogos -parameterName "CloneProjectLogos" -defaultValue $true $ProcessCloningOption = Test-OctopusProcessCloningParameter -ParameterValue $ProcessCloningOption $ProcessEnvironmentScopingMatch = Test-OctopusScopeMatchParameter -ParameterName "ProcessEnvironmentScopingMatch" -ParameterValue $ProcessEnvironmentScopingMatch -DefaultValue "SkipUnlessPartialMatch" -SingleValueItem $false @@ -82,6 +84,7 @@ $CloneScriptOptions = @{ CloneProjectChannelRules = $CloneProjectChannelRules; CloneProjectVersioningReleaseCreationSettings = $CloneProjectVersioningReleaseCreationSettings; CloneProjectDeploymentProcess = $CloneProjectDeploymentProcess; + CloneProjectLogos = $CloneProjectLogos; ProcessEnvironmentScopingMatch = $ProcessEnvironmentScopingMatch; ProcessChannelScopingMatch = $ProcessChannelScopingMatch; ProcessTenantTagScopingMatch = $ProcessTenantTagScopingMatch; diff --git a/src/Cloners/ProjectCloner.ps1 b/src/Cloners/ProjectCloner.ps1 index a72cfdf..8e35201 100644 --- a/src/Cloners/ProjectCloner.ps1 +++ b/src/Cloners/ProjectCloner.ps1 @@ -53,7 +53,11 @@ function Copy-OctopusProjects Copy-OctopusProjectVariables -sourceChannelList $sourceChannels -destinationChannelList $destinationChannels -destinationProject $destinationProject -sourceProject $project -destinationData $DestinationData -sourceData $SourceData -cloneScriptOptions $CloneScriptOptions Copy-OctopusProjectChannelRules -sourceChannelList $sourceChannels -destinationChannelList $destinationChannels -destinationProject $destinationProject -sourceData $SourceData -destinationData $DestinationData -cloneScriptOptions $CloneScriptOptions $destinationProject = Copy-OctopusProjectReleaseVersioningSettings -sourceData $sourceData -sourceProject $project -sourceChannels $sourceChannels -destinationData $destinationData -destinationProject $destinationProject -destinationChannels $destinationChannels -CloneScriptOptions $CloneScriptOptions - Copy-OctopusItemLogo -sourceItem $project -destinationItem $destinationProject -sourceData $SourceData -destinationData $DestinationData -CloneScriptOptions $CloneScriptOptions + + if ($CloneScriptOptions.CloneProjectLogos -eq $true) + { + Copy-OctopusItemLogo -sourceItem $project -destinationItem $destinationProject -sourceData $SourceData -destinationData $DestinationData -CloneScriptOptions $CloneScriptOptions + } } Write-OctopusPostCloneCleanUpHeader "*****************Ending Clone for all projects***************" diff --git a/src/Cloners/TenantCloner.ps1 b/src/Cloners/TenantCloner.ps1 index d6ad444..9b2781e 100644 --- a/src/Cloners/TenantCloner.ps1 +++ b/src/Cloners/TenantCloner.ps1 @@ -35,7 +35,10 @@ function Copy-OctopusTenants $destinationTenant = Save-OctopusTenant -Tenant $tenantToAdd -destinationData $destinationData $destinationData.TenantList += $destinationTenant - Copy-OctopusItemLogo -sourceItem $tenant -destinationItem $destinationTenant -sourceData $SourceData -destinationData $DestinationData -CloneScriptOptions $CloneScriptOptions + if ($CloneScriptOptions.CloneTenantLogos -eq $true) + { + Copy-OctopusItemLogo -sourceItem $tenant -destinationItem $destinationTenant -sourceData $SourceData -destinationData $DestinationData -CloneScriptOptions $CloneScriptOptions + } } elseif ($firstRun -eq $false) { diff --git a/src/Cloners/TenantVariableCloner.ps1 b/src/Cloners/TenantVariableCloner.ps1 index f218a9e..e0808ff 100644 --- a/src/Cloners/TenantVariableCloner.ps1 +++ b/src/Cloners/TenantVariableCloner.ps1 @@ -125,7 +125,7 @@ function Copy-OctopusTenantProjectVariables Write-OctopusChangeLog " - No update to $($projectTemplateVariable.Label) for Environment $($destinationEnvironment.Name) because it is using the default value" continue } - elseif ($sourceHasValue -eq $false -and $destinationHasValue -eq $true -and $CloneScriptOptions.OverwriteExistingVariables -eq $true) + elseif ($sourceHasValue -eq $false -and $destinationHasValue -eq $true -and $CloneScriptOptions.OverwriteExistingVariables.ToString() -eq "$true") { Write-OctopusVerbose "The source tenant is using the default value on the source, but the destination is not and overwrite variables is true, Resetting to default value" Write-OctopusChangeLog " - Resetting $($projectTemplateVariable.Label) for Environment $($destinationEnvironment.Name) to default" @@ -134,7 +134,7 @@ function Copy-OctopusTenantProjectVariables continue } - elseif ($sourceHasValue -eq $false -and $destinationHasValue -eq $true -and $CloneScriptOptions.OverwriteExistingVariables -eq $false) + elseif ($sourceHasValue -eq $false -and $destinationHasValue -eq $true -and $CloneScriptOptions.OverwriteExistingVariables.ToString() -eq "$false") { Write-OctopusVerbose "The source doesn't have a value but the destination does, overwrite is set to false, so leaving as is" Write-OctopusChangeLog " - No update to $($projectTemplateVariable.Label) for Environment $($destinationEnvironment.Name) because overwrite is set to false (would reset to default)" @@ -242,7 +242,7 @@ function Copy-OctopusTenantLibraryVariables Write-OctopusChangeLog " - No update to $($projectTemplateVariable.Label) for Environment $($destinationEnvironment.Name) because it is using the default value" continue } - elseif ($sourceHasValue -eq $false -and $destinationHasValue -eq $true -and $CloneScriptOptions.OverwriteExistingVariables -eq $true) + elseif ($sourceHasValue -eq $false -and $destinationHasValue -eq $true -and $CloneScriptOptions.OverwriteExistingVariables.ToString() -eq "$true") { Write-OctopusVerbose "The source tenant is using the default value on the source, but the destination is not and overwrite variables is true, Resetting to default value" Write-OctopusChangeLog " - Resetting $($projectTemplateVariable.Label) for Environment $($destinationEnvironment.Name) to default" @@ -250,7 +250,7 @@ function Copy-OctopusTenantLibraryVariables $destinationTenantVariables.LibraryVariables.$($matchingVariableSetId).Variables.PSObject.Properties.Remove($destinationVariableTemplateId) continue } - elseif ($sourceHasValue -eq $false -and $destinationHasValue -eq $true -and $CloneScriptOptions.OverwriteExistingVariables -eq $false) + elseif ($sourceHasValue -eq $false -and $destinationHasValue -eq $true -and $CloneScriptOptions.OverwriteExistingVariables.ToString() -eq "$false") { Write-OctopusVerbose "The source doesn't have a value but the destination does, overwrite is set to false, so leaving as is" Write-OctopusChangeLog " - No update to $($projectTemplateVariable.Label) because overwrite is set to false (would reset to default)" diff --git a/src/Cloners/VariableSetValuesCloner.ps1 b/src/Cloners/VariableSetValuesCloner.ps1 index eeb4aa1..8bad4c9 100644 --- a/src/Cloners/VariableSetValuesCloner.ps1 +++ b/src/Cloners/VariableSetValuesCloner.ps1 @@ -160,7 +160,7 @@ function Copy-OctopusVariableSetValues Write-OctopusPostCloneCleanUp "The variable $variableName is a sensitive variable, value set to 'Dummy Value'" } - if ($CloneScriptOptions.OverwriteExistingVariables.ToLower().Trim() -eq "addnewwithdefaultvalue") + if ($CloneScriptOptions.OverwriteExistingVariables.ToString().ToLower().Trim() -eq "addnewwithdefaultvalue") { Write-OctopusPostCloneCleanUp "The variable $variableName is a new variable and the OverwriteExistingVariables was set to AddNewWithDefaultValue, adding value set to 'REPLACE ME'" $octopusVariable.Value = "REPLACE ME" @@ -173,7 +173,7 @@ function Copy-OctopusVariableSetValues $DestinationVariableSetVariables.Variables += $octopusVariable } - elseif ($variableMatchType -eq "ScopeMatch" -and $CloneScriptOptions.OverwriteExistingVariables -ne $true) + elseif ($variableMatchType -eq "ScopeMatch" -and $CloneScriptOptions.OverwriteExistingVariables.ToString() -ne "$true") { Write-OctopusVerbose "The variable $variableName already exists on the destination with matching scope and you elected to only copy over new items, skipping this one." Write-OctopusChangeLog " - $variableName already exists with the following scope, skipping" diff --git a/src/Core/ParameterVerification.ps1 b/src/Core/ParameterVerification.ps1 index 1936265..4adc701 100644 --- a/src/Core/ParameterVerification.ps1 +++ b/src/Core/ParameterVerification.ps1 @@ -115,7 +115,7 @@ function Test-OctopusOverwriteExistingVariablesParameter return $false } - if ($parameterValue -ne $true -and $parameterValue -ne $false -and $parameterValue.ToLower().Trim() -ne "addnewwithdefaultvalue") + if ($parameterValue.ToString() -ne "$true" -and $parameterValue.ToString() -ne "$false" -and $parameterValue.ToString().ToLower().Trim() -ne "addnewwithdefaultvalue") { Write-OctopusCritical "The parameter OverwriteExistingVariables is set to $parameterValue. Acceptable values are $true, $false or AddNewWithDefaultValue" exit 1 diff --git a/src/Core/Util.ps1 b/src/Core/Util.ps1 index 1d7cbad..1ede4dd 100644 --- a/src/Core/Util.ps1 +++ b/src/Core/Util.ps1 @@ -370,7 +370,8 @@ function Add-PropertyIfMissing $objectToTest, $propertyName, $propertyValue, - $overwriteIfExists) + $overwriteIfExists + ) if ((Test-OctopusObjectHasProperty -objectToTest $objectToTest -propertyName $propertyName) -eq $false) { @@ -378,7 +379,7 @@ function Add-PropertyIfMissing return $true } - elseif ($null -ne $overwriteIfExists -and $overwriteIfExists -eq $true -and ((Test-OctopusObjectHasProperty -objectToTest $objectToTest -propertyName $propertyName) -eq $false)) + elseif ([string]::IsNullOrWhiteSpace($overwriteIfExists) -eq $false -and $overwriteIfExists.ToString() -eq "$true" -and ((Test-OctopusObjectHasProperty -objectToTest $objectToTest -propertyName $propertyName) -eq $false)) { $objectToTest.$propertyName = $propertyValue