From 4b3a03841b57385248c1c552e3dc91bf24221f7a Mon Sep 17 00:00:00 2001 From: smerle33 Date: Fri, 10 Feb 2023 11:50:24 +0100 Subject: [PATCH 01/24] chore(debug pipeline): add cpu architecture to pushing infos --- Jenkinsfile_k8s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index abfedf5df..b067e1020 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -247,7 +247,7 @@ pipeline { // else we would loose the docker image if (pkr_var_image_type == 'docker' && pkr_var_tag_name != null) { stage('Publish all tags for Docker image') { - echo "Pushing jenkinsciinfra/jenkins-agent-${pkr_var_agent_os_type}:${pkr_var_tag_name} & jenkinsciinfra/jenkins-agent-${pkr_var_agent_os_type}:latest" + echo "Pushing jenkinsciinfra/jenkins-agent-${pkr_var_agent_os_type}:${pkr_var_tag_name} & jenkinsciinfra/jenkins-agent-${pkr_var_agent_os_type}:latest for ${pkr_var_architecture}" infra.withDockerPushCredentials { sh 'docker push --all-tags jenkinsciinfra/jenkins-agent-${agent_type}' } From 17abb4347df88aa1c6f9b7a453038ab6fa60a27f Mon Sep 17 00:00:00 2001 From: smerle33 Date: Mon, 13 Feb 2023 11:35:13 +0100 Subject: [PATCH 02/24] chore(docker): adding a manifest to reenable both amd and arm publish --- Jenkinsfile_k8s | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index b067e1020..02b4eb6ab 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -259,6 +259,20 @@ pipeline { } } } + stage('Build Docker Manifest') { + when { + expression { + return env.TAG_NAME != null + } + } + steps { + sh 'docker manifest create \ + jenkinsciinfra/jenkins-agent-${agent_type}:latest \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' + sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' + } + } } } } From 4b7c349b17498a44ecd3353373aca1ca6c10f186 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Mon, 13 Feb 2023 11:41:14 +0100 Subject: [PATCH 03/24] chore indentation --- Jenkinsfile_k8s | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index 02b4eb6ab..69f723c19 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -258,19 +258,19 @@ pipeline { } } } - } - stage('Build Docker Manifest') { - when { - expression { - return env.TAG_NAME != null + stage('Build Docker Manifest') { + when { + expression { + return env.TAG_NAME != null + } + } + steps { + sh 'docker manifest create \ + jenkinsciinfra/jenkins-agent-${agent_type}:latest \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' + sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' } - } - steps { - sh 'docker manifest create \ - jenkinsciinfra/jenkins-agent-${agent_type}:latest \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' - sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' } } } From 692f8f40b1a7344f1d5f4f83ae94633eb7dbaaf5 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Mon, 13 Feb 2023 11:42:53 +0100 Subject: [PATCH 04/24] chore indentation --- Jenkinsfile_k8s | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index 69f723c19..db95c14ca 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -258,21 +258,21 @@ pipeline { } } } - stage('Build Docker Manifest') { - when { - expression { - return env.TAG_NAME != null - } - } - steps { - sh 'docker manifest create \ - jenkinsciinfra/jenkins-agent-${agent_type}:latest \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' - sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' - } + } + } + stage('Build Docker Manifest') { + when { + expression { + return env.TAG_NAME != null } } + steps { + sh 'docker manifest create \ + jenkinsciinfra/jenkins-agent-${agent_type}:latest \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' + sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' + } } } } From d86ad7257c01770d774a25cbe5ec76cd4df47de3 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Mon, 13 Feb 2023 14:05:29 +0100 Subject: [PATCH 05/24] move block --- Jenkinsfile_k8s | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index db95c14ca..a975c947c 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -257,22 +257,23 @@ pipeline { } } } + stage('Build Docker Manifest') { + when { + expression { + return env.TAG_NAME != null + } + } + steps { + sh 'docker manifest create \ + jenkinsciinfra/jenkins-agent-${agent_type}:latest \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' + sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' + } + } } } } - stage('Build Docker Manifest') { - when { - expression { - return env.TAG_NAME != null - } - } - steps { - sh 'docker manifest create \ - jenkinsciinfra/jenkins-agent-${agent_type}:latest \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' - sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' - } - } + } } From 61912d706a317706091acf83bdc6efecc5d57244 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Mon, 13 Feb 2023 14:44:28 +0100 Subject: [PATCH 06/24] add architecture cpu to manifest tags --- Jenkinsfile_k8s | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index a975c947c..446b32b22 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -249,7 +249,7 @@ pipeline { stage('Publish all tags for Docker image') { echo "Pushing jenkinsciinfra/jenkins-agent-${pkr_var_agent_os_type}:${pkr_var_tag_name} & jenkinsciinfra/jenkins-agent-${pkr_var_agent_os_type}:latest for ${pkr_var_architecture}" infra.withDockerPushCredentials { - sh 'docker push --all-tags jenkinsciinfra/jenkins-agent-${agent_type}' + sh 'docker push --all-tags jenkinsciinfra/jenkins-agent-${agent_type}:${pkr_var_architecture}' } } } @@ -269,6 +269,12 @@ pipeline { --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' + + sh 'docker manifest create \ + jenkinsciinfra/jenkins-agent-${agent_type}:${pkr_var_tag_name} \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' + sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:${pkr_var_tag_name}' } } } From aee19397d94ce1675aff8df8f3fe03a05c9d959c Mon Sep 17 00:00:00 2001 From: smerle33 Date: Mon, 13 Feb 2023 15:22:56 +0100 Subject: [PATCH 07/24] change variable as within sh --- Jenkinsfile_k8s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index 446b32b22..f20e43a68 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -249,7 +249,7 @@ pipeline { stage('Publish all tags for Docker image') { echo "Pushing jenkinsciinfra/jenkins-agent-${pkr_var_agent_os_type}:${pkr_var_tag_name} & jenkinsciinfra/jenkins-agent-${pkr_var_agent_os_type}:latest for ${pkr_var_architecture}" infra.withDockerPushCredentials { - sh 'docker push --all-tags jenkinsciinfra/jenkins-agent-${agent_type}:${pkr_var_architecture}' + sh 'docker push --all-tags jenkinsciinfra/jenkins-agent-${agent_type}:${cpu_architecture}' } } } From b03c3e03af99967c0e28ce95c81c5caf6e24cc06 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Mon, 13 Feb 2023 17:24:16 +0100 Subject: [PATCH 08/24] as we specify each tag, we cannot use alltags anymore .... --- Jenkinsfile_k8s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index f20e43a68..04d1074d0 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -249,7 +249,7 @@ pipeline { stage('Publish all tags for Docker image') { echo "Pushing jenkinsciinfra/jenkins-agent-${pkr_var_agent_os_type}:${pkr_var_tag_name} & jenkinsciinfra/jenkins-agent-${pkr_var_agent_os_type}:latest for ${pkr_var_architecture}" infra.withDockerPushCredentials { - sh 'docker push --all-tags jenkinsciinfra/jenkins-agent-${agent_type}:${cpu_architecture}' + sh 'docker push jenkinsciinfra/jenkins-agent-${agent_type}:${cpu_architecture}' } } } From dbcd7866d2a47687af737a7bcc788483e555b835 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Mon, 13 Feb 2023 18:02:03 +0100 Subject: [PATCH 09/24] adding docker tag manually --- Jenkinsfile_k8s | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index 04d1074d0..9d5ebdcbb 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -242,6 +242,8 @@ pipeline { // Execute build only for this matrix cell's setup retry(count: 2, conditions: [kubernetesAgent(handleNonKubernetes: true), nonresumable()]) { sh 'packer build -timestamp-ui -force -only="${PKR_VAR_image_type}.${PKR_VAR_agent_os_type}" ./' + // adding manually a cpu architecture tag to the docker image + sh 'docker tag jenkinsciinfra/jenkins-agent-${PKR_VAR_agent_os_type}:${PKR_VAR_architecture}' } // if docker and building a tag, push to dockerhub from inside the node // else we would loose the docker image @@ -249,7 +251,7 @@ pipeline { stage('Publish all tags for Docker image') { echo "Pushing jenkinsciinfra/jenkins-agent-${pkr_var_agent_os_type}:${pkr_var_tag_name} & jenkinsciinfra/jenkins-agent-${pkr_var_agent_os_type}:latest for ${pkr_var_architecture}" infra.withDockerPushCredentials { - sh 'docker push jenkinsciinfra/jenkins-agent-${agent_type}:${cpu_architecture}' + sh 'docker push --all-tags jenkinsciinfra/jenkins-agent-${agent_type}' } } } From 9e7c160b8dbe10b2cd230a0cd223f4576c6fccc6 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Tue, 14 Feb 2023 09:52:40 +0100 Subject: [PATCH 10/24] debug to save time --- provisioning/ubuntu-provision.sh | 54 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/provisioning/ubuntu-provision.sh b/provisioning/ubuntu-provision.sh index b96a8c509..28a64d525 100755 --- a/provisioning/ubuntu-provision.sh +++ b/provisioning/ubuntu-provision.sh @@ -737,36 +737,36 @@ function main() { install_ssh_requirements # Ensure that OpenSSH CLI and SSH agent are installed setuser # Define user Jenkins before all (to allow installing stuff in its home dir) install_asdf # Before all the others but after the jenkins home is created - install_chromium install_docker - install_datadog - install_JA_requirements - install_qemu - install_python - install_git_gitlfs - install_jdk - install_docker_compose - install_maven - install_hadolint - install_cst - install_jxreleaseversion - install_azurecli - install_gh - install_vagrant - install_ruby - install_yq - install_packer - install_updatecli - install_awscli - install_netlifydeploy - install_terraform - install_kubectl - install_tfsec + # install_chromium + # install_datadog + # install_JA_requirements + # install_qemu + # install_python + # install_git_gitlfs + # install_jdk + # install_docker_compose + # install_maven + # install_hadolint + # install_cst + # install_jxreleaseversion + # install_azurecli + # install_gh + # install_vagrant + # install_ruby + # install_yq + # install_packer + # install_updatecli + # install_awscli + # install_netlifydeploy + # install_terraform + # install_kubectl + # install_tfsec + # install_nodejs + # install_playwright_dependencies install_goss - install_nodejs - install_playwright_dependencies cleanup } main -sanity_check +# sanity_check From 5eb0b22b3f70f5dd7fff6ee96ec5bc9f009993d9 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Tue, 14 Feb 2023 09:53:09 +0100 Subject: [PATCH 11/24] move docker manifest to bottom --- Jenkinsfile_k8s | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index 9d5ebdcbb..dd3baf32e 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -243,7 +243,7 @@ pipeline { retry(count: 2, conditions: [kubernetesAgent(handleNonKubernetes: true), nonresumable()]) { sh 'packer build -timestamp-ui -force -only="${PKR_VAR_image_type}.${PKR_VAR_agent_os_type}" ./' // adding manually a cpu architecture tag to the docker image - sh 'docker tag jenkinsciinfra/jenkins-agent-${PKR_VAR_agent_os_type}:${PKR_VAR_architecture}' + sh 'docker tag "jenkinsciinfra/jenkins-agent-${PKR_VAR_agent_os_type}-${PKR_VAR_agent_os_version}:latest" "jenkinsciinfra/jenkins-agent-${PKR_VAR_agent_os_type}-${PKR_VAR_agent_os_version}:${PKR_VAR_architecture}"' } // if docker and building a tag, push to dockerhub from inside the node // else we would loose the docker image @@ -259,29 +259,28 @@ pipeline { } } } - stage('Build Docker Manifest') { - when { - expression { - return env.TAG_NAME != null - } - } - steps { - sh 'docker manifest create \ - jenkinsciinfra/jenkins-agent-${agent_type}:latest \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' - sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' - - sh 'docker manifest create \ - jenkinsciinfra/jenkins-agent-${agent_type}:${pkr_var_tag_name} \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' - sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:${pkr_var_tag_name}' - } - } } } } + stage('Build Docker Manifest') { + when { + expression { + return env.TAG_NAME != null + } + } + steps { + sh 'docker manifest create \ + jenkinsciinfra/jenkins-agent-${agent_type}:latest \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' + sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' + sh 'docker manifest create \ + jenkinsciinfra/jenkins-agent-${agent_type}:${env.TAG_NAME} \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' + sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:${env.TAG_NAME}' + } + } } } From 4fd606ea70bfc6eabd2a5994d4560db51f0fae11 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Tue, 14 Feb 2023 09:58:43 +0100 Subject: [PATCH 12/24] scripted and with docker credential --- Jenkinsfile_k8s | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index dd3baf32e..d10bd9127 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -269,17 +269,21 @@ pipeline { } } steps { - sh 'docker manifest create \ - jenkinsciinfra/jenkins-agent-${agent_type}:latest \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' - sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' + script { + infra.withDockerPushCredentials { + sh 'docker manifest create \ + jenkinsciinfra/jenkins-agent-${agent_type}:latest \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' + sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' - sh 'docker manifest create \ - jenkinsciinfra/jenkins-agent-${agent_type}:${env.TAG_NAME} \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ - --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' - sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:${env.TAG_NAME}' + sh 'docker manifest create \ + jenkinsciinfra/jenkins-agent-${agent_type}:${env.TAG_NAME} \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ + --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' + sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:${env.TAG_NAME}' + } + } } } } From daefd3857eba2f841cfe141846a87f56b55357d1 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Tue, 14 Feb 2023 10:02:06 +0100 Subject: [PATCH 13/24] change null to empty --- Jenkinsfile_k8s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index d10bd9127..c1d7b38cd 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -265,7 +265,7 @@ pipeline { stage('Build Docker Manifest') { when { expression { - return env.TAG_NAME != null + return env.TAG_NAME != '' } } steps { From 6748853e674562d1f3716e3c18abe69c8af3c88f Mon Sep 17 00:00:00 2001 From: smerle33 Date: Tue, 14 Feb 2023 10:11:25 +0100 Subject: [PATCH 14/24] debug to save time --- Jenkinsfile_k8s | 115 ++++++++++++++++--------------- provisioning/ubuntu-provision.sh | 2 +- 2 files changed, 59 insertions(+), 58 deletions(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index c1d7b38cd..76a6e723b 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -78,62 +78,62 @@ pipeline { } } } - stage('GC on AWS us-east-2') { - agent { - kubernetes { - yaml podAgentDefinition - } - } - environment { - AWS_ACCESS_KEY_ID = credentials('packer-aws-access-key-id') - AWS_SECRET_ACCESS_KEY = credentials('packer-aws-secret-access-key') - AWS_DEFAULT_REGION = 'us-east-2' - } - steps { - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh './cleanup/aws.sh' - sh './cleanup/aws_images.sh' - } - } - } - stage('GC on Azure') { - agent { - kubernetes { - yaml podAgentDefinition - } - } - environment { - PACKER_AZURE = credentials('packer-azure-serviceprincipal') - } - steps { - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh 'az login --service-principal -u "$PACKER_AZURE_CLIENT_ID" -p "$PACKER_AZURE_CLIENT_SECRET" -t "$PACKER_AZURE_TENANT_ID"' - sh 'az account set -s "$PACKER_AZURE_SUBSCRIPTION_ID"' - sh './cleanup/azure.sh' - } - } - } - stage('Updatecli') { - steps { - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - script { - // TODO: Implement https://github.com/jenkins-infra/pipeline-library/issues/518 to allow using the updatecli() library function - withCredentials([ - usernamePassword( - credentialsId: 'github-app-updatecli-on-jenkins-infra', - usernameVariable: 'USERNAME_VALUE', // Setting this variable is mandatory, even if of not used when the credentials is a githubApp one - passwordVariable: 'UPDATECLI_GITHUB_TOKEN' - ) - ]) { - sh 'updatecli diff --values ./updatecli/values.yaml --config ./updatecli/updatecli.d' - if (env.BRANCH_IS_PRIMARY) { - sh 'updatecli apply --values ./updatecli/values.yaml --config ./updatecli/updatecli.d' - } - } - } - } - } - } + // stage('GC on AWS us-east-2') { + // agent { + // kubernetes { + // yaml podAgentDefinition + // } + // } + // environment { + // AWS_ACCESS_KEY_ID = credentials('packer-aws-access-key-id') + // AWS_SECRET_ACCESS_KEY = credentials('packer-aws-secret-access-key') + // AWS_DEFAULT_REGION = 'us-east-2' + // } + // steps { + // catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + // sh './cleanup/aws.sh' + // sh './cleanup/aws_images.sh' + // } + // } + // } + // stage('GC on Azure') { + // agent { + // kubernetes { + // yaml podAgentDefinition + // } + // } + // environment { + // PACKER_AZURE = credentials('packer-azure-serviceprincipal') + // } + // steps { + // catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + // sh 'az login --service-principal -u "$PACKER_AZURE_CLIENT_ID" -p "$PACKER_AZURE_CLIENT_SECRET" -t "$PACKER_AZURE_TENANT_ID"' + // sh 'az account set -s "$PACKER_AZURE_SUBSCRIPTION_ID"' + // sh './cleanup/azure.sh' + // } + // } + // } + // stage('Updatecli') { + // steps { + // catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + // script { + // // TODO: Implement https://github.com/jenkins-infra/pipeline-library/issues/518 to allow using the updatecli() library function + // withCredentials([ + // usernamePassword( + // credentialsId: 'github-app-updatecli-on-jenkins-infra', + // usernameVariable: 'USERNAME_VALUE', // Setting this variable is mandatory, even if of not used when the credentials is a githubApp one + // passwordVariable: 'UPDATECLI_GITHUB_TOKEN' + // ) + // ]) { + // sh 'updatecli diff --values ./updatecli/values.yaml --config ./updatecli/updatecli.d' + // if (env.BRANCH_IS_PRIMARY) { + // sh 'updatecli apply --values ./updatecli/values.yaml --config ./updatecli/updatecli.d' + // } + // } + // } + // } + // } + // } } } stage('Packer Images') { @@ -150,7 +150,8 @@ pipeline { axis { name 'compute_type' // "azure-arm" stands for "Azure Resource Manager", unrelated to arm64 CPU - values 'amazon-ebs', 'azure-arm', 'docker' + //values 'amazon-ebs', 'azure-arm', 'docker' + values 'docker' } } excludes { diff --git a/provisioning/ubuntu-provision.sh b/provisioning/ubuntu-provision.sh index 28a64d525..22671d3fe 100755 --- a/provisioning/ubuntu-provision.sh +++ b/provisioning/ubuntu-provision.sh @@ -738,13 +738,13 @@ function main() { setuser # Define user Jenkins before all (to allow installing stuff in its home dir) install_asdf # Before all the others but after the jenkins home is created install_docker + install_jdk # install_chromium # install_datadog # install_JA_requirements # install_qemu # install_python # install_git_gitlfs - # install_jdk # install_docker_compose # install_maven # install_hadolint From 611a2d00f46e78f134b13364670ff3ec568ebc98 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Tue, 14 Feb 2023 10:47:49 +0100 Subject: [PATCH 15/24] manually add the agent_type to the docker manifest --- Jenkinsfile_k8s | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index 76a6e723b..062121175 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -145,6 +145,7 @@ pipeline { } axis { name 'agent_type' + // make sure to port any addition to the list of agent types to the Build Docker Manifest stage if it's docker related values 'ubuntu-20.04', 'windows-2019', 'windows-2022' } axis { @@ -271,6 +272,7 @@ pipeline { } steps { script { + env.agent_type='ubuntu-20.04' infra.withDockerPushCredentials { sh 'docker manifest create \ jenkinsciinfra/jenkins-agent-${agent_type}:latest \ From 17767d6edfaab37f04286a4399dac0e2525b72ac Mon Sep 17 00:00:00 2001 From: smerle33 Date: Tue, 14 Feb 2023 14:36:05 +0100 Subject: [PATCH 16/24] manually add the agent_type to the docker manifest --- Jenkinsfile_k8s | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index 062121175..4a02dc6d2 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -270,9 +270,11 @@ pipeline { return env.TAG_NAME != '' } } + environment { + agent_type = 'ubuntu-20.04' + } steps { script { - env.agent_type='ubuntu-20.04' infra.withDockerPushCredentials { sh 'docker manifest create \ jenkinsciinfra/jenkins-agent-${agent_type}:latest \ @@ -281,10 +283,10 @@ pipeline { sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' sh 'docker manifest create \ - jenkinsciinfra/jenkins-agent-${agent_type}:${env.TAG_NAME} \ + jenkinsciinfra/jenkins-agent-${agent_type}:${TAG_NAME} \ --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' - sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:${env.TAG_NAME}' + sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:${TAG_NAME}' } } } From e40e45a4cbb8d4cc828b8c5e2a48b22cb7b64614 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Wed, 15 Feb 2023 09:10:18 +0100 Subject: [PATCH 17/24] change TagName test to null to avoid manifest on PR but just on tag creation --- Jenkinsfile_k8s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index 4a02dc6d2..fb91c8531 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -267,7 +267,7 @@ pipeline { stage('Build Docker Manifest') { when { expression { - return env.TAG_NAME != '' + return env.TAG_NAME != null } } environment { From 551a6e136699beb17105aa1ef8fc80b3164c42f3 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Wed, 15 Feb 2023 09:26:47 +0100 Subject: [PATCH 18/24] revert all debug/quick commit --- Jenkinsfile_k8s | 115 +++++++++++++++---------------- provisioning/ubuntu-provision.sh | 58 ++++++++-------- 2 files changed, 86 insertions(+), 87 deletions(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index fb91c8531..a5eb1412a 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -78,62 +78,62 @@ pipeline { } } } - // stage('GC on AWS us-east-2') { - // agent { - // kubernetes { - // yaml podAgentDefinition - // } - // } - // environment { - // AWS_ACCESS_KEY_ID = credentials('packer-aws-access-key-id') - // AWS_SECRET_ACCESS_KEY = credentials('packer-aws-secret-access-key') - // AWS_DEFAULT_REGION = 'us-east-2' - // } - // steps { - // catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - // sh './cleanup/aws.sh' - // sh './cleanup/aws_images.sh' - // } - // } - // } - // stage('GC on Azure') { - // agent { - // kubernetes { - // yaml podAgentDefinition - // } - // } - // environment { - // PACKER_AZURE = credentials('packer-azure-serviceprincipal') - // } - // steps { - // catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - // sh 'az login --service-principal -u "$PACKER_AZURE_CLIENT_ID" -p "$PACKER_AZURE_CLIENT_SECRET" -t "$PACKER_AZURE_TENANT_ID"' - // sh 'az account set -s "$PACKER_AZURE_SUBSCRIPTION_ID"' - // sh './cleanup/azure.sh' - // } - // } - // } - // stage('Updatecli') { - // steps { - // catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - // script { - // // TODO: Implement https://github.com/jenkins-infra/pipeline-library/issues/518 to allow using the updatecli() library function - // withCredentials([ - // usernamePassword( - // credentialsId: 'github-app-updatecli-on-jenkins-infra', - // usernameVariable: 'USERNAME_VALUE', // Setting this variable is mandatory, even if of not used when the credentials is a githubApp one - // passwordVariable: 'UPDATECLI_GITHUB_TOKEN' - // ) - // ]) { - // sh 'updatecli diff --values ./updatecli/values.yaml --config ./updatecli/updatecli.d' - // if (env.BRANCH_IS_PRIMARY) { - // sh 'updatecli apply --values ./updatecli/values.yaml --config ./updatecli/updatecli.d' - // } - // } - // } - // } - // } - // } + stage('GC on AWS us-east-2') { + agent { + kubernetes { + yaml podAgentDefinition + } + } + environment { + AWS_ACCESS_KEY_ID = credentials('packer-aws-access-key-id') + AWS_SECRET_ACCESS_KEY = credentials('packer-aws-secret-access-key') + AWS_DEFAULT_REGION = 'us-east-2' + } + steps { + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh './cleanup/aws.sh' + sh './cleanup/aws_images.sh' + } + } + } + stage('GC on Azure') { + agent { + kubernetes { + yaml podAgentDefinition + } + } + environment { + PACKER_AZURE = credentials('packer-azure-serviceprincipal') + } + steps { + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh 'az login --service-principal -u "$PACKER_AZURE_CLIENT_ID" -p "$PACKER_AZURE_CLIENT_SECRET" -t "$PACKER_AZURE_TENANT_ID"' + sh 'az account set -s "$PACKER_AZURE_SUBSCRIPTION_ID"' + sh './cleanup/azure.sh' + } + } + } + stage('Updatecli') { + steps { + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + script { + // TODO: Implement https://github.com/jenkins-infra/pipeline-library/issues/518 to allow using the updatecli() library function + withCredentials([ + usernamePassword( + credentialsId: 'github-app-updatecli-on-jenkins-infra', + usernameVariable: 'USERNAME_VALUE', // Setting this variable is mandatory, even if of not used when the credentials is a githubApp one + passwordVariable: 'UPDATECLI_GITHUB_TOKEN' + ) + ]) { + sh 'updatecli diff --values ./updatecli/values.yaml --config ./updatecli/updatecli.d' + if (env.BRANCH_IS_PRIMARY) { + sh 'updatecli apply --values ./updatecli/values.yaml --config ./updatecli/updatecli.d' + } + } + } + } + } + } } } stage('Packer Images') { @@ -151,8 +151,7 @@ pipeline { axis { name 'compute_type' // "azure-arm" stands for "Azure Resource Manager", unrelated to arm64 CPU - //values 'amazon-ebs', 'azure-arm', 'docker' - values 'docker' + values 'amazon-ebs', 'azure-arm', 'docker' } } excludes { diff --git a/provisioning/ubuntu-provision.sh b/provisioning/ubuntu-provision.sh index 22671d3fe..a5bb03b1b 100755 --- a/provisioning/ubuntu-provision.sh +++ b/provisioning/ubuntu-provision.sh @@ -737,36 +737,36 @@ function main() { install_ssh_requirements # Ensure that OpenSSH CLI and SSH agent are installed setuser # Define user Jenkins before all (to allow installing stuff in its home dir) install_asdf # Before all the others but after the jenkins home is created - install_docker - install_jdk - # install_chromium - # install_datadog - # install_JA_requirements - # install_qemu - # install_python - # install_git_gitlfs - # install_docker_compose - # install_maven - # install_hadolint - # install_cst - # install_jxreleaseversion - # install_azurecli - # install_gh - # install_vagrant - # install_ruby - # install_yq - # install_packer - # install_updatecli - # install_awscli - # install_netlifydeploy - # install_terraform - # install_kubectl - # install_tfsec - # install_nodejs - # install_playwright_dependencies - install_goss + install_goss # needed by the pipeline + install_docker # needed by the pipeline + install_jdk # needed by the pipeline + install_chromium + install_datadog + install_JA_requirements + install_qemu + install_python + install_git_gitlfs + install_docker_compose + install_maven + install_hadolint + install_cst + install_jxreleaseversion + install_azurecli + install_gh + install_vagrant + install_ruby + install_yq + install_packer + install_updatecli + install_awscli + install_netlifydeploy + install_terraform + install_kubectl + install_tfsec + install_nodejs + install_playwright_dependencies cleanup } main -# sanity_check +sanity_check From a4f0e6a151ae708c6a7ca393c709873e2f8a770c Mon Sep 17 00:00:00 2001 From: smerle33 Date: Wed, 15 Feb 2023 12:06:33 +0100 Subject: [PATCH 19/24] docker tag only for docker build --- Jenkinsfile_k8s | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index a5eb1412a..400125218 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -244,7 +244,9 @@ pipeline { retry(count: 2, conditions: [kubernetesAgent(handleNonKubernetes: true), nonresumable()]) { sh 'packer build -timestamp-ui -force -only="${PKR_VAR_image_type}.${PKR_VAR_agent_os_type}" ./' // adding manually a cpu architecture tag to the docker image - sh 'docker tag "jenkinsciinfra/jenkins-agent-${PKR_VAR_agent_os_type}-${PKR_VAR_agent_os_version}:latest" "jenkinsciinfra/jenkins-agent-${PKR_VAR_agent_os_type}-${PKR_VAR_agent_os_version}:${PKR_VAR_architecture}"' + if (pkr_var_image_type == 'docker') { + sh 'docker tag "jenkinsciinfra/jenkins-agent-${PKR_VAR_agent_os_type}-${PKR_VAR_agent_os_version}:latest" "jenkinsciinfra/jenkins-agent-${PKR_VAR_agent_os_type}-${PKR_VAR_agent_os_version}:${PKR_VAR_architecture}"' + } } // if docker and building a tag, push to dockerhub from inside the node // else we would loose the docker image From 409946392a7ce2a08ea6eda0838cacc7cbfde3e0 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Wed, 15 Feb 2023 14:16:28 +0100 Subject: [PATCH 20/24] change git ppa to release-candidate for edge version --- provisioning/ubuntu-provision.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provisioning/ubuntu-provision.sh b/provisioning/ubuntu-provision.sh index a5bb03b1b..9da436abc 100755 --- a/provisioning/ubuntu-provision.sh +++ b/provisioning/ubuntu-provision.sh @@ -265,7 +265,7 @@ function install_git_gitlfs() { if [ -n "${GIT_LINUX_VERSION}" ] then ## a specific git version is required: search it on the official git PPA repositories - add-apt-repository -y ppa:git-core/ppa + add-apt-repository -y ppa:git-core/candidate install_package_version git "${GIT_LINUX_VERSION}" else ## No git version: install the latest git available in the default repos From 0f62ca361e4cd29015af76f5e3418729bac3080c Mon Sep 17 00:00:00 2001 From: smerle33 Date: Wed, 15 Feb 2023 15:00:17 +0100 Subject: [PATCH 21/24] revert to the core ppa for git, assuming a revert on the version to install to the last available one --- provisioning/ubuntu-provision.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provisioning/ubuntu-provision.sh b/provisioning/ubuntu-provision.sh index 9da436abc..a5bb03b1b 100755 --- a/provisioning/ubuntu-provision.sh +++ b/provisioning/ubuntu-provision.sh @@ -265,7 +265,7 @@ function install_git_gitlfs() { if [ -n "${GIT_LINUX_VERSION}" ] then ## a specific git version is required: search it on the official git PPA repositories - add-apt-repository -y ppa:git-core/candidate + add-apt-repository -y ppa:git-core/ppa install_package_version git "${GIT_LINUX_VERSION}" else ## No git version: install the latest git available in the default repos From fa38636ca8688c249144117deb37d9ba11d34131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20MERLE?= <95630726+smerle33@users.noreply.github.com> Date: Thu, 16 Feb 2023 09:59:45 +0100 Subject: [PATCH 22/24] Update Jenkinsfile_k8s Co-authored-by: Damien Duportal --- Jenkinsfile_k8s | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index 400125218..e29cf5aa0 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -272,6 +272,8 @@ pipeline { } } environment { + // Static variable definition as this stage is outside the matrix scope + // Improvement: pass dynamically the list of images from the matrix (e.g. use full scripted pipeline) to support other Docker agent types (such as windows-2019 or windows-2022) agent_type = 'ubuntu-20.04' } steps { From 9d934ac0e0e87de7bbb39cd75b2428acb9487581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20MERLE?= <95630726+smerle33@users.noreply.github.com> Date: Thu, 16 Feb 2023 10:00:00 +0100 Subject: [PATCH 23/24] Update Jenkinsfile_k8s Co-authored-by: Damien Duportal --- Jenkinsfile_k8s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index e29cf5aa0..e52fcb083 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -283,7 +283,7 @@ pipeline { jenkinsciinfra/jenkins-agent-${agent_type}:latest \ --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' - sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:latest' + sh 'docker manifest push jenkinsciinfra/jenkins-agent-"${agent_type}":latest' sh 'docker manifest create \ jenkinsciinfra/jenkins-agent-${agent_type}:${TAG_NAME} \ From 32e779c1994d3092c4754b26caffd08d79559f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20MERLE?= <95630726+smerle33@users.noreply.github.com> Date: Thu, 16 Feb 2023 10:00:16 +0100 Subject: [PATCH 24/24] Update Jenkinsfile_k8s Co-authored-by: Damien Duportal --- Jenkinsfile_k8s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_k8s b/Jenkinsfile_k8s index e52fcb083..04e842762 100644 --- a/Jenkinsfile_k8s +++ b/Jenkinsfile_k8s @@ -289,7 +289,7 @@ pipeline { jenkinsciinfra/jenkins-agent-${agent_type}:${TAG_NAME} \ --amend jenkinsciinfra/jenkins-agent-${agent_type}:arm64 \ --amend jenkinsciinfra/jenkins-agent-${agent_type}:amd64' - sh 'docker manifest push jenkinsciinfra/jenkins-agent-${agent_type}:${TAG_NAME}' + sh 'docker manifest push jenkinsciinfra/jenkins-agent-"${agent_type}":"${TAG_NAME}"' } } }