No such property for Jenkins while running groovy script from command line -


using script console i'm able execute below script without issues. whenever run script command line got below error. added "execute groovy script" job throwing same error. "execute system groovy script" works fine. there wrong i'm doing? can me plz

import  jenkins.model.jenkins.*; jenkins = jenkins.model.jenkins.instance  def item = jenkins.getitem("3rd-libraries") def build = item.getlastbuild()  println build.isinprogress()  caught: groovy.lang.missingpropertyexception: no such property: jenkins class: job groovy.lang.missingpropertyexception: no such property: jenkins class: job         @ job.run(job.groovy:2) 

jenkins:2.18

groovy: groovy version: 2.4.6 jvm: 1.7.0_40 vendor: oracle corporation os: linux

i think you're missing def declaration jenkins.

the second line should read;

def jenkins = jenkins.model.jenkins.instance 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -