Closed vjda closed 6 years ago
After digging into the issue I realized I didn't select the container in the pipeline and if you don't specify it, Kubernetes plugin assumes as default container the jnlp. That's why Jenkins X could not find the gradle and maven binaries... 😓
Do you know if the default container can be selected in The Kubernetes Pod Template section? If the pod template is defined in the pipeline this can be done using the flag defaultContainer
. See an example:
pipeline {
agent {
kubernetes {
label 'mypod'
customWorkspace 'some/other/path'
defaultContainer 'maven'
yamlFile 'KubernetesPod.yaml'
}
}
stages {
stage('Run maven') {
steps {
sh 'mvn -version'
sh "echo Workspace dir is ${pwd()}"
}
}
}
}
Reference https://github.com/jenkinsci/kubernetes-plugin#declarative-pipeline
In order to this might be helpul for others, a default container can be configured in a pipeline as follow:
pipeline {
agent {
kubernetes {
label 'jenkins-gradle'
defaultContainer 'gradle'
}
}
stages {
stage('gradle') {
steps {
sh "gradle --version"
}
}
}
}
I can close the issue. Cheers!
Summary
Hi all, first of all, I love Jenkins X. It's awesome, so thanks guys! When Jenkins X launchs a gradle-builder pod to execute a job which invokes any gradle command always throws an error such as:
However, if I connect to the pod using
jx rsh gradle-id
I can execute gradle commands as expected. I'm very confused because I'm using a fresh-installation with the default configuration.Steps to reproduce the behavior
This is my pipeline which reproduces the issue:
Console output:
As you may notice, Jenkins X cannot find the path /opt/gradle where gradle should be located. Besides, when I connect directly to the pod, the PATH enviroment var is different than the displayed in the Jenkins console. I mean:
Jx version
The output of
jx version
is:Kubernetes cluster
What kind of Kubernetes cluster are you using & how did you create it? I'm using an EKS cluster and it was created with terraform and then JenkinsX installed with
jx install --provider=eks
Operating system / Environment
EKS with Kubernetes version v1.10.3
Expected behavior
Pod builders should be able to execute gradle or maven commands.
Actual behavior
Gradle and Maven pods do not find gradle and maven binaries.
Thanks in advance!!