fabric8io / jenkins-docker

docker file for a jenkins docker image
84 stars 96 forks source link

groovy.lang.MissingMethodException for Kubernetes Client #130

Closed 3r1co closed 7 years ago

3r1co commented 7 years ago

Hi,

I tried to use the latest version of the Fabric8 Jenkins Image (fabric8/jenkins-docker:2.2.328) , but when I try to run something a Pod, it throws an exception.

Here the code snippet: kubernetes.pod('buildpod').withImage('alpine').inside { sh 'echo "Hello from Alpine"' }

And the exception: hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate.setAlwaysPullImage() is applicable for argument types: (null) values: [null] Possible solutions: setAlwaysPullImage(boolean), isAlwaysPullImage()

Could you please tell me when I could do on that?

rawlingsj commented 7 years ago

@3r1co what version of the shared pipeline library are you using? i.e. what version is at the end of the @Library annotation at the top of your Jenkinsfile?

FWIW even though the jenkins yaml that is in maven central it's not part of the latest fabric8-platform release.

The latest release version is v2.2.311 https://github.com/fabric8io/fabric8-jenkinsfile-library/blob/v2.2.311/maven/CanaryReleaseStageAndApprovePromote/Jenkinsfile#L2

3r1co commented 7 years ago

Hi @rawlingsj , I tried now with the version 2.2.311, but now I have the following issue:

` [test] Running shell script /var/jenkins_home/workspace/test # sh -c echo $$ > '/var/jenkins_home/workspace/

test@tmp/durable-ad77d560/pid'; jsc=durable-68f8352ee94861d5684fcd48c4f301cc; JE NKINS_SERVER_COOKIE=$jsc '/var/jenkins_home/workspace/test@tmp/durable-ad77d560/ script.sh' > '/var/jenkins_home/workspace/test@tmp/durable-ad77d560/jenkins-log. txt' 2>&1; echo $? > '/var/jenkins_home/workspace/test@tmp/durable-ad77d560/jenk

ins-result.txt' /bin/sh: can't create /var/jenkins_home/workspace/test@tmp/durable-ad77d560/pid: nonexistent directory /bin/sh: can't create /var/jenkins_home/workspace/test@tmp/durable-ad77d560/jenkins-log.txt: nonexistent directory /bin/sh: can't create /var/jenkins_home/workspace/test@tmp/durable-ad77d560/jenkins-result.txt: nonexistent directory /var/jenkins_home/workspace/test # exit

command terminated with non-zero exit code: Error executing in Docker Container: 1[Pipeline] } `

The test script is the same. Any idea?

3r1co commented 7 years ago

Ok, it works when I use a PV to share the workspace. Sorry for the confusion.

barbarosalp commented 6 years ago

@3r1co can you please give some brief info about how did you solve it? Thanks.

3r1co commented 6 years ago

Hi @barbarosalp , I'm facing this issue mostly when the UID running the image in kubernetes.pod('buildpod').withImage('alpine').inside { sh 'echo "Hello from Alpine"' } is different from the one from running the jenkins slave, e.g. Jenkins slave is running is 0 (root), but the alpine mentioned above is running as 1000 (cloud-user). Another reason why this can happen of the workspace is not shared between the Jenkins slave and the other Kubernetes pod. You can overcome this by creating a PVC wit the name "jenkins-workspace", which will be automatically mounted.

joaoferrao commented 6 years ago

I'm having this issue by simply following all the tutorials at jenkins.io I tried the simpler and the more complete ones, both with Blue Ocean as well as the the base version with suggested pluggins.

Is there a good suggestion on how to solve this?

I'm running Jenkins on a docker with

docker run -u root -p 8080:8080 -v $(pwd)/jenkins-data:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/home --privileged jenkinsci/blueocean