-
Bug
-
Resolution: Won't Do
-
Trivial
-
None
-
Jenkins 2.289.3
org.csanchez.jenkins.plugins:kubernetes:1.21.3
Similar (not same) to JENKINS-49762
I am using withMaven() to execute maven with a custom settings.xml whilst using Kubernetes to run the agent.
The pipeline is:
pipeline { agent { kubernetes { cloud 'openshift' defaultContainer 'tools' yamlFile 'jenkins-agent-pod.yml' idleMinutes 30 } } stages { stage("Build") { steps { withMaven(mavenSettingsConfig: 'maven-dev-settings') { sh "pwd" sh "ps aux" sh "mvn clean" } } } } }
jenkins-agent-pod.yml describes a pod having 2 containers, jnlp and tools, and tools has all the needed build tools preconfigured (i.e. mvn, node, etc.)
The build output is:
[Pipeline] stage [Pipeline] { (Build) [Pipeline] withMaven [withMaven] Options: [] [withMaven] Available options: [withMaven] using JDK installation provided by the build agent Executing sh script inside container tools of pod sandbox-common-master-25-ct67v-dnjpm-p6vf9 Executing command: "/bin/sh" "-c" "which mvn" exit which: no mvn in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin) [withMaven] Maven installation not specified in the 'withMaven()' step and not found on the build agent [Pipeline] { [Pipeline] sh + pwd /home/jenkins/agent/workspace/SANDBOX_common_master [Pipeline] sh + ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND jenkins 1 0.1 0.0 4384 380 ? Ss 07:37 0:00 sleep infinity ---- omitted lines --- [Pipeline] sh + mvn clean /home/jenkins/agent/workspace/SANDBOX_common_master@tmp/durable-9a796c34/script.sh: line 1: mvn: command not found [Pipeline] } [Pipeline] // withMaven [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // container [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] } [Pipeline] // podTemplate [Pipeline] End of Pipeline [Bitbucket] Notifying commit build result [Bitbucket] Build result notified ERROR: script returned exit code 127 Finished: FAILURE
Judging by the logs, it seems that the commands are run on the tools container, however mvn is not found, which leads me to think that the jnlp container is used instead.
Manually, when I run "which mvn" on both containers:
- tools: /usr/share/maven/bin/mvn
- jnlp: which: no mvn in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
Also, worth mentioning, I've also tried with specifying a Maven installation (which only had the MAVEN_HOME set) - still without success.
If you assess this as a "Not A Defect" - please advise a workaround or a better way of achieving this.