Hi, I am trying to submit following groovy script to a Jenkins server with curl command, but got compilation error. It has no problem if I run it in Jenkins script console. Here is my groovy script 'groovy5':
script=for (item in Jenkins.instance.items) { println "item.class.name"; if (item.class.name == "hudson.model.FreeStyleProject") { if (item.lastBuild != null) { if(item.lastBuild.result == hudson.model.Result.FAILURE) { println (" "+item.name) ; /* No problem if : println (item.name); */ } } } } Here is the curl command and error message o7devl@my-machine:~ <o7devl@dsysadm-cm06:%7E/subversion_devl/cm-repos/svn_test/hooks>> curl -s -d @groovy5 -X POST http://o7devl:apitoken@jenkinsserver:28080/jenkins/scriptText <http://o7devl:6406ccf5b1a04a1e50ffd80e93f886d2@dlsysadm-ap72:28080/jenkins/scriptText> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 1: unexpected token: item @ line 1, column 307. println (" " item.name) ^ 1 error It looks like the '+' operator got erased.In additon, if I combine the inner 2 if statement like this: if (item.lastBuild != null && item.lastBuild.result == hudson.model.Result.FAILURE) I got this error: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 1: expecting ')', found '' @ line 1, column 190. if (item.lastBuild != null ^ The && sign looks like get lost. What cause this problem? Thanks. -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/63a292d6-31ad-4bab-9f05-9b1b462daa73%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.