Skip to content

Commit 0272ffa

Browse files
committed
fix(Jenkinsfile): avoid pod-level runAs; use nova-ci container runAs + checkout in nova-ci
Kubernetes plugin PodTemplateUtils.combine() only merges runAsUser/runAsGroup into pod securityContext and drops fsGroup, so jnlp could not use the workspace. - Remove pod securityContext from inline yaml (jnlp uses image default for agent dir). - Set runAsUser/runAsGroup on nova-ci containerTemplate only. - Run Code checkout inside container('nova-ci') so workspace files match build UID.
1 parent 1445523 commit 0272ffa

1 file changed

Lines changed: 31 additions & 29 deletions

File tree

Jenkinsfile

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
// https://nvidia.atlassian.net/wiki/spaces/BLOS/pages/2147264305/NFS+scratch+space+for+Blossom+Jenkins+job
1515
// Export: ipp1-cdot01-col01:/vol/scratch1/scratch.epeer_blossom → mountPath /scratch
1616
// Set job parameters RUN_AS_UID / RUN_AS_GID from `id` on a Linux host (same as wiki Step 3–4).
17-
// fsGroup matches RUN_AS_GID so the jnlp workspace emptyDir is writable (non-root agent).
17+
// Do not set pod-level securityContext.runAsUser: the Kubernetes plugin merge drops fsGroup and
18+
// breaks jnlp's /home/jenkins/agent. jnlp stays image-default (root); nova-ci uses runAsUser below;
19+
// Code checkout runs in container('nova-ci') so the workspace is writable by the build UID.
1820
// - TAP summary: GNU gawk + /usr/local/share/nova-ci/tap-summary.gawk (from ci/Dockerfile).
1921
// - CI image: see ci/Dockerfile — clang/llvm, ccache, make, git, colossus CLI (add in private layer),
2022
// jq, curl, openssh-client, Rust-for-Linux (rustup nightly + rust-src / rustfmt / clippy), etc.
@@ -57,10 +59,6 @@ podTemplate(
5759
apiVersion: v1
5860
kind: Pod
5961
spec:
60-
securityContext:
61-
runAsUser: ${runUid.toInteger()}
62-
runAsGroup: ${runGid.toInteger()}
63-
fsGroup: ${runGid.toInteger()}
6462
volumes:
6563
- name: scratch
6664
nfs:
@@ -85,7 +83,9 @@ spec:
8583
name: 'nova-ci',
8684
image: ciImage,
8785
ttyEnabled: true,
88-
command: 'cat'
86+
command: 'cat',
87+
runAsUser: runUid,
88+
runAsGroup: runGid,
8989
)
9090
]
9191
) {
@@ -108,29 +108,31 @@ spec:
108108

109109
stageName = 'Code checkout'
110110
stage(stageName) {
111-
githubHelper.updateCommitStatus("${BUILD_URL}", "${stageName} Running", GitHubCommitState.PENDING)
112-
if ('Open'.equalsIgnoreCase(githubHelper.getPRState())) {
113-
checkout changelog: true, poll: false, scm: [
114-
$class: 'GitSCM',
115-
branches: [[name: "pr/${githubHelper.getPRNumber()}"]],
116-
extensions: [],
117-
userRemoteConfigs: [[
118-
credentialsId: 'github-token',
119-
url: githubHelper.getCloneUrl(),
120-
refspec: '+refs/pull/*/head:refs/remotes/origin/pr/*'
121-
]]
122-
]
123-
} else if ('Merged'.equalsIgnoreCase(githubHelper.getPRState())) {
124-
checkout changelog: true, poll: false, scm: [
125-
$class: 'GitSCM',
126-
branches: [[name: githubHelper.getMergedSHA()]],
127-
extensions: [],
128-
userRemoteConfigs: [[
129-
credentialsId: 'github-token',
130-
url: githubHelper.getCloneUrl(),
131-
refspec: '+refs/pull/*/merge:refs/remotes/origin/pr/*'
132-
]]
133-
]
111+
container('nova-ci') {
112+
githubHelper.updateCommitStatus("${BUILD_URL}", "${stageName} Running", GitHubCommitState.PENDING)
113+
if ('Open'.equalsIgnoreCase(githubHelper.getPRState())) {
114+
checkout changelog: true, poll: false, scm: [
115+
$class: 'GitSCM',
116+
branches: [[name: "pr/${githubHelper.getPRNumber()}"]],
117+
extensions: [],
118+
userRemoteConfigs: [[
119+
credentialsId: 'github-token',
120+
url: githubHelper.getCloneUrl(),
121+
refspec: '+refs/pull/*/head:refs/remotes/origin/pr/*'
122+
]]
123+
]
124+
} else if ('Merged'.equalsIgnoreCase(githubHelper.getPRState())) {
125+
checkout changelog: true, poll: false, scm: [
126+
$class: 'GitSCM',
127+
branches: [[name: githubHelper.getMergedSHA()]],
128+
extensions: [],
129+
userRemoteConfigs: [[
130+
credentialsId: 'github-token',
131+
url: githubHelper.getCloneUrl(),
132+
refspec: '+refs/pull/*/merge:refs/remotes/origin/pr/*'
133+
]]
134+
]
135+
}
134136
}
135137
}
136138

0 commit comments

Comments
 (0)