Purpose | Script |
Reflection | activeJobs = hudson.model.Hudson.instance.items.findAll{job -> job.isBuildable()} for (j in activeJobs) { describe (j.asProject().getLastBuild()) } def describe (o) { println (o.toString() + " ("+o.getClass()+")") println ("\tList of fields") for( field in o.getClass().getFields() ) { println "\t\t"+field.getType().getName() + "\t"+field.getName() + "\t("+field.get(o)+")" } println ("\tList of methods") for( method in o.getClass().getMethods() ) { result = "("+method.getParameterTypes().length+" args)" if (method.getParameterTypes().length == 0) { if ((method.toString().indexOf("java.lang.Object")==-1) && (method.toString().indexOf(".get")==-1)) result = method.invoke(o) else result = "java lang method" } println "\t\t"+method.toString() + "\t"+result } println "***END***" } |
Delete workspace | deleteWorkspaceIfNotRunning ("ApolloQAP_FindBugs") def deleteWorkspaceIfNotRunning (jobName) { job = hudson.model.Hudson.instance.items.find{job -> job.name == jobName} println ("Delete workspace for "+job.getName() + " if not under progress") if (!job.isBuilding()) { println (" >>> Delete workspace for "+job.getName() + " ...") job.doDoWipeOutWorkspace() } else { println (" >>> Do not delete workspace for "+job.getName() + " because it is currently under progress") } } |
trigger job if given job failed | urJobName = "Staging_ForZiv_triggerSironInCaseOfFailure" triggeredJobName = "InvokeKitchenSiron" job = hudson.model.Hudson.instance.items.find{job -> job.name == curJobName} run = job.getLastBuild() println (job.name + " last build is " + run.number + " with status " + run.result) if (run.result == run.result.FAILURE) { println ("Job failed so trigger " + triggeredJobName) triggeredJob = hudson.model.Hudson.instance.items.find{job -> job.name == "InvokeKitchenSiron"} // triggeredJob.newBuild() } else { println ("Job passed") } |
trigger a job | job = hudson.model.Hudson.instance.items.find{job -> job.name == "name"} job.newBuild() |
As a software developer, I open XML files all the time. I a heavy commercial XML editor. But nothing can compare to a small, thin and free XML editor like 'foxe'. A great feature is has is the alignment of long XML strings to readable XML format (Shift-F8). It help lot of times when the XML file was generated by some tool and was not readable. Homepage: http://www.firstobject.com/dn_editor.htm
Comments