Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
hack/debug copy jenkins-agent.ps1 in context
Browse files Browse the repository at this point in the history
  • Loading branch information
lemeurherve committed Jul 8, 2023
1 parent ea6efc5 commit 9125788
Show file tree
Hide file tree
Showing 9 changed files with 584 additions and 345 deletions.
147 changes: 56 additions & 91 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,6 @@ pipeline {
not { buildingTag() }
}
steps {
// script {
// def parallelBuilds = [:]
// def images = ['jdk11-windowsservercore-ltsc2019', 'jdk11-nanoserver-1809', 'jdk17-windowsservercore-ltsc2019', 'jdk17-nanoserver-1809']
// for (unboundImage in images) {
// def image = unboundImage // Bind variable before the closure
// // Prepare a map of the steps to run in parallel
// parallelBuilds[image] = {
// // Allocate a node for each image to avoid filling disk
// node('docker-windows') {
// checkout scm
// powershell '& ./make.ps1 -Build ' + image + ' test'
// junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/**/junit-results.xml')
// }
// }
// }
// // Peform the parallel execution
// parallel parallelBuilds
// }
powershell '& ./build.ps1 test'
}
post {
Expand All @@ -59,23 +41,6 @@ pipeline {
}
steps {
script {
// // This function is defined in the jenkins-infra/pipeline-library
// infra.withDockerCredentials {
// powershell '& ./make.ps1 -PushVersions -VersionTag $env:TAG_NAME publish'
// }

// // Directly from docker-agent
// def tagItems = env.TAG_NAME.split('-')
// if(tagItems.length == 2) {
// def dockerAgentVersion = tagItems[0]
// def buildNumber = tagItems[1]
// // This function is defined in the jenkins-infra/pipeline-library
// infra.withDockerCredentials {
// powershell "& ./build.ps1 -PushVersions -DockerAgentVersion $dockerAgentVersion -BuildNumber $buildNumber -DisableEnvProps publish"
// }
// }
// debug
echo "=== env.TAG_NAME: ${env:TAG_NAME}"
infra.withDockerCredentials {
// TODO: check if this function has the same beahvior in build.ps1 vs make.ps1
powershell '& ./build.ps1 -PushVersions -VersionTag $env:TAG_NAME publish'
Expand All @@ -85,62 +50,62 @@ pipeline {
}
}
}
// stage('Linux') {
// agent {
// label "docker&&linux"
// }
// options {
// timeout(time: 30, unit: 'MINUTES')
// }
// environment {
// JENKINS_REPO = "${infra.isTrusted() ? 'jenkins' : 'jenkins4eval'}/inbound-agent"
// }
// stages {
// stage('Prepare Docker') {
// steps {
// sh '''
// docker buildx create --use
// docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
// '''
// }
// }
// stage('Build and Test') {
// // This stage is the "CI" and should be run on all code changes triggered by a code change
// when {
// not { buildingTag() }
// }
// steps {
// sh 'make build'
// sh 'make test'
// // If the tests are passing for Linux AMD64, then we can build all the CPU architectures
// sh 'docker buildx bake --file docker-bake.hcl linux'
// }
// post {
// always {
// junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/*.xml')
// }
// }
// }
// stage('Deploy to DockerHub') {
// // This stage is the "CD" and should only be run when a tag triggered the build
// when {
// buildingTag()
// }
// steps {
// script {
// // This function is defined in the jenkins-infra/pipeline-library
// infra.withDockerCredentials {
// sh '''
// export IMAGE_TAG="${TAG_NAME}"
// export ON_TAG=true
// docker buildx bake --push --file docker-bake.hcl linux
// '''
// }
// }
// }
// }
// }
// }
stage('Linux') {
agent {
label "docker&&linux"
}
options {
timeout(time: 30, unit: 'MINUTES')
}
environment {
JENKINS_REPO = "${infra.isTrusted() ? 'jenkins' : 'jenkins4eval'}/inbound-agent"
}
stages {
stage('Prepare Docker') {
steps {
sh '''
docker buildx create --use
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
'''
}
}
stage('Build and Test') {
// This stage is the "CI" and should be run on all code changes triggered by a code change
when {
not { buildingTag() }
}
steps {
sh 'make build'
sh 'make test'
// If the tests are passing for Linux AMD64, then we can build all the CPU architectures
sh 'docker buildx bake --file docker-bake.hcl linux'
}
post {
always {
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/*.xml')
}
}
}
stage('Deploy to DockerHub') {
// This stage is the "CD" and should only be run when a tag triggered the build
when {
buildingTag()
}
steps {
script {
// This function is defined in the jenkins-infra/pipeline-library
infra.withDockerCredentials {
sh '''
export IMAGE_TAG="${TAG_NAME}"
export ON_TAG=true
docker buildx bake --push --file docker-bake.hcl linux
'''
}
}
}
}
}
}
}
}
}
Expand Down
8 changes: 0 additions & 8 deletions build-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,22 @@ services:
build:
context: ./windows/nanoserver-1809/
args:
JAVA_HOME: "C:/openjdk-11"
JAVA_VERSION: "11.0.19_7"
VERSION: ${DOCKER_AGENT_VERSION}
jdk17-nanoserver-1809:
image: jdk17-nanoserver-1809
build:
context: ./windows/nanoserver-1809/
args:
JAVA_HOME: "C:/openjdk-17"
JAVA_VERSION: "17.0.7_7"
VERSION: ${DOCKER_AGENT_VERSION}
jdk11-windowsservercore-ltsc2019:
image: jdk11-windowsservercore-ltsc2019
build:
context: ./windows/windowsservercore-ltsc2019/
args:
JAVA_HOME: "C:/openjdk-11"
JAVA_VERSION: "11.0.19_7"
VERSION: ${DOCKER_AGENT_VERSION}
jdk17-windowsservercore-ltsc2019:
image: jdk17-windowsservercore-ltsc2019
build:
context: ./windows/windowsservercore-ltsc2019/
args:
JAVA_HOME: "C:/openjdk-17"
JAVA_VERSION: "17.0.7_7"
VERSION: ${DOCKER_AGENT_VERSION}
5 changes: 4 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ function Test-Image {

$env:AGENT_IMAGE = $ImageName
$env:IMAGE_FOLDER = Invoke-Expression "$baseDockerCmd config" 2>$null | yq -r ".services.${ImageName}.build.context"
$env:VERSION = "$DockerAgentVersion-$BuildNumber"
# TODO: review build number removal (?)
# $env:VERSION = "$DockerAgentVersion-$BuildNumber"
$env:VERSION = $DockerAgentVersion

Write-Host "= TEST: image folder ${env:IMAGE_FOLDER}, version ${env:VERSION}"

if(Test-Path ".\target\$ImageName") {
Remove-Item -Recurse -Force ".\target\$ImageName"
Expand Down
Loading

0 comments on commit 9125788

Please sign in to comment.