diff --git a/Jenkinsfile b/Jenkinsfile index 9f175dd2b..fe3efe99f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,24 +10,28 @@ def mavenEnv(Map params = [:], Closure body) { retry(count: attempts, conditions: [kubernetesAgent(handleNonKubernetes: true), nonresumable()]) { echo 'Attempt ' + ++attempt + ' of ' + attempts // no Dockerized tests; https://github.com/jenkins-infra/documentation/blob/master/ci.adoc#container-agents - node("maven-$params.jdk") { - timeout(120) { - sh 'mvn -version' - // Exclude DigitalOcean artifact caching proxy provider, currently unreliable on BOM builds - // TODO: remove when https://github.com/jenkins-infra/helpdesk/issues/3481 is fixed - infra.withArtifactCachingProxy(env.ARTIFACT_CACHING_PROXY_PROVIDER != 'do') { - withEnv([ - "MAVEN_ARGS=${env.MAVEN_ARGS != null ? MAVEN_ARGS : ''} -B -ntp -Dmaven.repo.local=${WORKSPACE_TMP}/m2repo" - ]) { - body() + podTemplate( + cloud: 'cik8s-bom', + yaml: readTrusted('podTemplate.yaml'), + ) { + node(POD_LABEL) { + timeout(120) { + withEnv(["JAVA_HOME=/opt/jdk-$params.jdk"]) { + infra.withArtifactCachingProxy() { + withEnv([ + "MAVEN_ARGS=${env.MAVEN_ARGS != null ? MAVEN_ARGS : ''} -B -ntp -Dmaven.repo.local=${WORKSPACE_TMP}/m2repo" + ]) { + body() + } + } + if (junit(testResults: '**/target/surefire-reports/TEST-*.xml,**/target/failsafe-reports/TEST-*.xml').failCount > 0) { + // TODO JENKINS-27092 throw up UNSTABLE status in this case + error 'Some test failures, not going to continue' + } + } + } } } - if (junit(testResults: '**/target/surefire-reports/TEST-*.xml,**/target/failsafe-reports/TEST-*.xml').failCount > 0) { - // TODO JENKINS-27092 throw up UNSTABLE status in this case - error 'Some test failures, not going to continue' - } - } - } } } @@ -52,7 +56,10 @@ stage('prep') { withCredentials([ usernamePassword(credentialsId: 'app-ci.jenkins.io', usernameVariable: 'GITHUB_APP', passwordVariable: 'GITHUB_OAUTH') ]) { - sh 'bash prep.sh' + sh ''' + mvn -version + bash prep.sh + ''' } } dir('target') { diff --git a/podTemplate.yaml b/podTemplate.yaml new file mode 100644 index 000000000..20fcb9712 --- /dev/null +++ b/podTemplate.yaml @@ -0,0 +1,50 @@ +--- +apiVersion: "v1" +kind: "Pod" +spec: + containers: + - name: jnlp + image: jenkinsciinfra/jenkins-agent-ubuntu-22.04@sha256:0f007bec7835b0b7e383d12eac4f860af9fa9b35d53159f67348770f97d55ce6 + command: + - "/usr/local/bin/jenkins-agent" + env: + - name: "PATH" + value: "/opt/jdk-11/bin:/home/jenkins/.asdf/shims:/home/jenkins/.asdf/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" + - name: "ARTIFACT_CACHING_PROXY_PROVIDER" + value: "aws" + - name: "JENKINS_AGENT_WORKDIR" + value: "/home/jenkins/agent" + - name: "JENKINS_JAVA_OPTS" + value: "-XX:+PrintCommandLineFlags" + - name: "JENKINS_JAVA_BIN" + value: "/opt/jdk-11/bin/java" + resources: + limits: + memory: "8Gi" + cpu: "4" + requests: + memory: "8Gi" + cpu: "4" + securityContext: + privileged: false + volumeMounts: + - mountPath: "/home/jenkins/.m2/repository" + name: "volume-1" + readOnly: false + - mountPath: "/tmp" + name: "volume-0" + readOnly: false + volumes: + - emptyDir: + medium: "Memory" + name: "volume-0" + - emptyDir: + medium: "" + name: "volume-1" + nodeSelector: + ci.jenkins.io/agents-density: 23 + tolerations: + - key: "ci.jenkins.io/bom" + operator: "Equal" + value: "true" + effect: "NoSchedule"