I cannot run Groovy scripts in Jenkins. Let me give you an overview of my setup.
I run the official Jenkins docker image with the follow docker compose:
version: '2' services: jenkins: image: jenkins/jenkins:lts container_name: jenkins ports: - 8080:8080 volumes: - ./home:/var/jenkins_home
Jenkins is up & running as it should. I installed also the Groovy plugin http://wiki.jenkins-ci.org/display/JENKINS/Groovy+plugin .
Now I tried to run a simple Groovy script like this:
LSOUT = sh ( script: 'ls -al', returnStdout: true ).trim() echo "${LSOUT}"
But I cannot make it working. This is the error I am getting:
Building in workspace /var/jenkins_home/workspace/test_groovy [test_groovy] $ groovy /var/jenkins_home/workspace/test_groovy/hudson4423271822305767083.groovy Caught: groovy.lang.MissingMethodException: No signature of method: hudson4423271822305767083.sh() is applicable for argument types: (java.util.LinkedHashMap) values: [[script:ls -al, returnStdout:true]] Possible solutions: use([Ljava.lang.Object;), is(java.lang.Object), run(), run(), any(), use(java.util.List, groovy.lang.Closure) groovy.lang.MissingMethodException: No signature of method: hudson4423271822305767083.sh() is applicable for argument types: (java.util.LinkedHashMap) values: [[script:ls -al, returnStdout:true]] Possible solutions: use([Ljava.lang.Object;), is(java.lang.Object), run(), run(), any(), use(java.util.List, groovy.lang.Closure) at hudson4423271822305767083.run(hudson4423271822305767083.groovy:1) Build step 'Execute Groovy script' marked build as failure Finished: FAILURE
Groovy is also installed as package in the container. Any idea?
#docker #jenkins