kubernetes job tries to run locally on windows master, why?
This is a sample jenkinsfile i tried to use
pipeline {
agent {
kubernetes {
cloud 'kub04'
defaultContainer 'kaniko'
yaml '''
kind: Pod
spec:
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:v1.6.0-debug
imagePullPolicy: Always
tty: true
command:
- /busybox/sh
- name: jnlp
image: jenkins/jnlp-slave:latest-jdk11
tty: true
'''
}
}
stages {
stage('Build with Kaniko') {
steps {
container(name: 'kaniko') {
sh '/kaniko/executor --help'
}
}
}
}
}
This is setup on jenkins running on Windows. What happens is - in the log - :
Running on testljpipeline-96-qt102-9sk88-qwr2q in /home/jenkins/agent/workspace/testljpipeline
[Pipeline] {
[Pipeline] container
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build with Kaniko)
[Pipeline] sh
sh: C:\Program Files\Git\bin\sh.exe: not found
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE
Why? What is going on here? The pods get spawned on k8s, but jenkins insists on running any commands locally.
I also tried adding the container(name: 'kaniko') { } section around the sh step, but to no avail
Posted Jun 1, 2023, 10:12 AM UTC
11
apparently there was a system-wide option that defined shell to that sh.exe, which was hard to spot.