From 60ac33c469b8921d4840c1428ac268189242e79d Mon Sep 17 00:00:00 2001 From: Damien Duportal Date: Thu, 5 May 2022 18:13:44 +0200 Subject: [PATCH] feat: add Windows Server 2022 VM templates Signed-off-by: Damien Duportal --- Jenkinsfile_k8s | 12 +++++++++++- build-jenkins-agent-windows.pkr.hcl | 6 +++--- datasources.pkr.hcl | 11 +++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index 73cdb0af5..ab866230c 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -87,7 +87,7 @@ pipeline { } axis { name 'agent_type' - values 'ubuntu-20.04', 'windows-2019' + values 'ubuntu-20.04', 'windows-2019', 'windows-2022' } axis { name 'compute_type' @@ -133,6 +133,16 @@ pipeline { values 'docker' } } + exclude { + axis { + name 'agent_type' + values 'windows-2022' + } + axis { + name 'compute_type' + values 'docker' + } + } } agent { label "linux-${env.cpu_architecture}-docker" diff --git a/build-jenkins-agent-windows.pkr.hcl b/build-jenkins-agent-windows.pkr.hcl index 6ddc8532f..368a84a07 100644 --- a/build-jenkins-agent-windows.pkr.hcl +++ b/build-jenkins-agent-windows.pkr.hcl @@ -50,6 +50,7 @@ build { provisioner "windows-restart" { max_retries = 3 } + # This provisioner must be the last for Azure builds, after reboots provisioner "powershell" { only = ["azure-arm.windows"] elevated_user = local.windows_winrm_user[var.image_type] @@ -64,15 +65,14 @@ build { source = "./provisioning/EC2-LaunchConfig.json" destination = "C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Config\\LaunchConfig.json" } + # This provisioner must be the last for AWS EBS builds, after reboots provisioner "powershell" { only = ["amazon-ebs.windows"] elevated_user = local.windows_winrm_user[var.image_type] elevated_password = build.Password # Ref. https:#docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-windows-user-data.html#user-data-scripts-subsequent inline = [ - "C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SendWindowsIsReady.ps1 -Schedule", - "C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\InitializeInstance.ps1 -Schedule", - "C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SysprepInstance.ps1 -NoShutdown" + "if($env:AGENT_OS_VERSION = '2019') { C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SendWindowsIsReady.ps1 -Schedule; C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\InitializeInstance.ps1 -Schedule; C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SysprepInstance.ps1 -NoShutdown;};" ] } } diff --git a/datasources.pkr.hcl b/datasources.pkr.hcl index e67efe24b..fef6521f8 100644 --- a/datasources.pkr.hcl +++ b/datasources.pkr.hcl @@ -20,3 +20,14 @@ data "amazon-ami" "windows-2019" { owners = ["amazon"] region = var.aws_region } + +data "amazon-ami" "windows-2022" { + filters = { + name = "Windows_Server-2022-English-Core-ContainersLatest-*" + root-device-type = "ebs" + virtualization-type = "hvm" + } + most_recent = true + owners = ["amazon"] + region = var.aws_region +}