diff --git a/.azuredevops/pipelineTemplates/module.jobs.deploy.yml b/.azuredevops/pipelineTemplates/module.jobs.deploy.yml index 4163583cc5..5e517b415c 100644 --- a/.azuredevops/pipelineTemplates/module.jobs.deploy.yml +++ b/.azuredevops/pipelineTemplates/module.jobs.deploy.yml @@ -108,8 +108,26 @@ jobs: # Load used functions . (Join-Path '$(System.DefaultWorkingDirectory)' 'utilities' 'pipelines' 'sharedScripts' 'Set-EnvironmentOnAgent.ps1') + # Define PS modules to install on the runner + $Modules = @( + @{ Name = 'Az.Accounts' }, + @{ Name = 'Az.Resources' } + ) + + # Additional PS modules need to be installed for the removal step in case it is enabled + if ('${{ parameters.removeDeployment}}' -eq 'true') { + $Modules += @( + @{ Name = 'Az.CognitiveServices' }, + @{ Name = 'Az.Compute' }, + @{ Name = 'Az.KeyVault' }, + @{ Name = 'Az.Monitor' }, + @{ Name = 'Az.OperationalInsights' }, + @{ Name = 'Az.RecoveryServices' } + ) + } + # Set agent up - Set-EnvironmentOnAgent + Set-EnvironmentOnAgent -PSModules $Modules # [Multi Repo] Support task #-------------------------- diff --git a/.azuredevops/pipelineTemplates/module.jobs.publish.yml b/.azuredevops/pipelineTemplates/module.jobs.publish.yml index c0ca0111d7..2d4e014332 100644 --- a/.azuredevops/pipelineTemplates/module.jobs.publish.yml +++ b/.azuredevops/pipelineTemplates/module.jobs.publish.yml @@ -108,8 +108,15 @@ jobs: # Load used functions . (Join-Path '$(System.DefaultWorkingDirectory)' 'utilities' 'pipelines' 'sharedScripts' 'Set-EnvironmentOnAgent.ps1') + # Define PS modules to install on the runner + $Modules = @( + @{ Name = 'Az.Accounts' }, + @{ Name = 'Az.ContainerRegistry' }, + @{ Name = 'Az.Resources' } + ) + # Set agent up - Set-EnvironmentOnAgent + Set-EnvironmentOnAgent -PSModules $Modules # [Multi Repo] Support task #-------------------------- diff --git a/.azuredevops/pipelineTemplates/module.jobs.validate.yml b/.azuredevops/pipelineTemplates/module.jobs.validate.yml index 062a5fb080..ff45280b39 100644 --- a/.azuredevops/pipelineTemplates/module.jobs.validate.yml +++ b/.azuredevops/pipelineTemplates/module.jobs.validate.yml @@ -115,8 +115,15 @@ jobs: # Load used functions . (Join-Path '$(moduleRepoRoot)' 'utilities' 'pipelines' 'sharedScripts' 'Set-EnvironmentOnAgent.ps1') + # Define PS modules to install on the runner + $Modules = @( + # This is the latest tested Pester version. Uncomment the next line in case of a future breaking change in the default version installed on the runner. + # @{ Name = 'Pester'; Version = '5.3.1' } + @{ Name = 'Az.Resources' } + ) + # Set agent up - Set-EnvironmentOnAgent + Set-EnvironmentOnAgent -PSModules $Modules # [Module Pester Test] task(s) #----------------------------- diff --git a/.github/actions/templates/publishModule/action.yml b/.github/actions/templates/publishModule/action.yml index de08822334..7feb663233 100644 --- a/.github/actions/templates/publishModule/action.yml +++ b/.github/actions/templates/publishModule/action.yml @@ -49,8 +49,15 @@ runs: # Load used functions . (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'sharedScripts' 'Set-EnvironmentOnAgent.ps1') + # Define PS modules to install on the runner + $Modules = @( + @{ Name = 'Az.Accounts' }, + @{ Name = 'Az.ContainerRegistry' }, + @{ Name = 'Az.Resources' } + ) + # Set agent up - Set-EnvironmentOnAgent + Set-EnvironmentOnAgent -PSModules $Modules - name: Azure Login uses: Azure/login@v1 diff --git a/.github/actions/templates/validateModuleDeployment/action.yml b/.github/actions/templates/validateModuleDeployment/action.yml index 361a2ef9d3..b1a2890b0e 100644 --- a/.github/actions/templates/validateModuleDeployment/action.yml +++ b/.github/actions/templates/validateModuleDeployment/action.yml @@ -36,8 +36,26 @@ runs: # Load used functions . (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'sharedScripts' 'Set-EnvironmentOnAgent.ps1') + # Define PS modules to install on the runner + $Modules = @( + @{ Name = 'Az.Accounts' }, + @{ Name = 'Az.Resources' } + ) + + # Additional PS modules need to be installed for the removal step in case it is enabled + if ('${{ inputs.removeDeployment}}' -eq 'true') { + $Modules += @( + @{ Name = 'Az.CognitiveServices' }, + @{ Name = 'Az.Compute' }, + @{ Name = 'Az.KeyVault' }, + @{ Name = 'Az.Monitor' }, + @{ Name = 'Az.OperationalInsights' }, + @{ Name = 'Az.RecoveryServices' } + ) + } + # Set agent up - Set-EnvironmentOnAgent + Set-EnvironmentOnAgent -PSModules $Modules - name: Azure Login uses: Azure/login@v1 with: diff --git a/.github/actions/templates/validateModulePester/action.yml b/.github/actions/templates/validateModulePester/action.yml index 227233f7b8..c3a9664aac 100644 --- a/.github/actions/templates/validateModulePester/action.yml +++ b/.github/actions/templates/validateModulePester/action.yml @@ -16,8 +16,15 @@ runs: # Load used functions . (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'sharedScripts' 'Set-EnvironmentOnAgent.ps1') + # Define PS modules to install on the runner + $Modules = @( + # This is the latest tested Pester version. Uncomment the next line in case of a future breaking change in the default version installed on the runner. + # @{ Name = 'Pester'; Version = '5.3.1' } + @{ Name = 'Az.Resources' } + ) + # Set agent up - Set-EnvironmentOnAgent + Set-EnvironmentOnAgent -PSModules $Modules - name: Azure Login uses: Azure/login@v1 diff --git a/utilities/pipelines/sharedScripts/Set-EnvironmentOnAgent.ps1 b/utilities/pipelines/sharedScripts/Set-EnvironmentOnAgent.ps1 index 8e9cf515b2..2b5fe9cbf3 100644 --- a/utilities/pipelines/sharedScripts/Set-EnvironmentOnAgent.ps1 +++ b/utilities/pipelines/sharedScripts/Set-EnvironmentOnAgent.ps1 @@ -78,12 +78,24 @@ Configure the current agent .DESCRIPTION Configure the current agent with e.g. the necessary PowerShell modules. -.PARAMETER Modules -Optional. The PowerShell modules that should be installed on the agent. Installs default set if not provided. -@{ - Name = 'Name' - Version = '1.0.0' # Optional -} +.PARAMETER PSModules +Optional. The PowerShell modules that should be installed on the agent. + +@( + @{ Name = 'Az.Accounts' }, + @{ Name = 'Az.Compute' }, + @{ Name = 'Az.Resources' }, + @{ Name = 'Az.ContainerRegistry' }, + @{ Name = 'Az.KeyVault' }, + @{ Name = 'Az.RecoveryServices' }, + @{ Name = 'Az.Monitor' }, + @{ Name = 'Az.CognitiveServices' }, + @{ Name = 'Az.OperationalInsights' }, + @{ + Name = 'Pester' + Version = '5.3.1' # Version is optional + } +) .EXAMPLE Set-EnvironmentOnAgent @@ -95,20 +107,7 @@ function Set-EnvironmentOnAgent { [CmdletBinding()] param ( [Parameter(Mandatory = $false)] - [Hashtable[]] $Modules = @( - @{ Name = 'Az.Accounts' }, - @{ Name = 'Az.Compute' }, - @{ Name = 'Az.Resources' }, - @{ Name = 'Az.NetAppFiles' }, - @{ Name = 'Az.Network' }, - @{ Name = 'Az.ContainerRegistry' }, - @{ Name = 'Az.KeyVault' }, - @{ Name = 'Az.RecoveryServices' }, - @{ Name = 'Az.Monitor' }, - @{ Name = 'Az.CognitiveServices' }, - @{ Name = 'Az.OperationalInsights' }, - @{ Name = 'Pester'; Version = '5.3.0' } - ) + [Hashtable[]] $PSModules = @() ) ###########################