Skip to content
Closed
41 changes: 24 additions & 17 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
}
}
}

Expand All @@ -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') {
Expand Down
50 changes: 50 additions & 0 deletions podTemplate.yaml
Original file line number Diff line number Diff line change
@@ -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"
Comment on lines +13 to +14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this get overridden?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC

infra.withArtifactCachingProxy(env.ARTIFACT_CACHING_PROXY_PROVIDER != 'do') {
should set the same variable?

Copy link
Member

@lemeurherve lemeurherve Apr 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're setting this ARTIFACT_CACHING_PROXY_PROVIDER variable value in every agent (except the Azure VM agents as it's not possible to set an env var on them AFAIK) in our infrastructure as code definitions.
This variable is then used in the infra.withArtifactCachingProxy function to determine which acp provider to use.
This variable is not set in the pipeline library.
Putting it in this podTemplate allows the correct selection of the AWS acp provider, without it it would default to the Azure one. (cf https://github.com/jenkins-infra/pipeline-library/blob/9e0f0a2f09a7c91b26824e706a8963598b685742/vars/infra.groovy#L101)

- 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be used, given

"MAVEN_ARGS=${env.MAVEN_ARGS != null ? MAVEN_ARGS : ''} -B -ntp -Dmaven.repo.local=${WORKSPACE_TMP}/m2repo"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a "copy-and-paste" of the pod yaml from the existing config defined by the admins of ci.jenkins.io. I would want to stick to this realit y as close as possible.

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"