Skip to content

Commit

Permalink
Merge branch 'main' into updatecli_11b252fe312e3e4a0a50125cfa991ac1e9…
Browse files Browse the repository at this point in the history
…07f973f0f8d5118761330f56a25a0a
  • Loading branch information
smerle33 authored Feb 17, 2023
2 parents 0e5f3e9 + 6c0bfb2 commit 6192d83
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
36 changes: 35 additions & 1 deletion Jenkinsfile_k8s
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -242,12 +243,16 @@ 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
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
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}'
}
Expand All @@ -260,5 +265,34 @@ pipeline {
}
}
}
stage('Build Docker Manifest') {
when {
expression {
return env.TAG_NAME != null
}
}
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 {
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}:${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}"'
}
}
}
}
}
}
6 changes: 3 additions & 3 deletions provisioning/ubuntu-provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -737,14 +737,15 @@ 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_goss # needed by the pipeline
install_docker # needed by the pipeline
install_jdk # needed by the pipeline
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
Expand All @@ -762,7 +763,6 @@ function main() {
install_terraform
install_kubectl
install_tfsec
install_goss
install_nodejs
install_playwright_dependencies
cleanup
Expand Down

0 comments on commit 6192d83

Please sign in to comment.