java.lang.IllegalStateException: no parent set on hudson.plugins.promoted_builds.PromotionProcess[Nightly]
at hudson.model.AbstractItem.getParent(AbstractItem.java:179)
at hudson.plugins.promoted_builds.PromotionProcess.getParent(PromotionProcess.java:140)
at hudson.plugins.promoted_builds.PromotionProcess.getOwner(PromotionProcess.java:148)
at hudson.plugins.promoted_builds.PromotionProcess.getAssignedLabel(PromotionProcess.java:195)
at hudson.model.Queue$Item.getAssignedLabel(Queue.java:1415)
at hudson.model.Node.canTake(Node.java:330)
at hudson.model.Queue$JobOffer.canTake(Queue.java:277)
at hudson.model.Queue.maintain(Queue.java:1049)
at hudson.model.Queue$MaintainTask.doRun(Queue.java:2048)
at hudson.triggers.SafeTimerTask.run(SafeTimerTask.java:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
import hudson.model.*import hudson.model.ItemGroupimport hudson.scm.*import java.util.*import hudson.plugins.promoted_builds.*import hudson.plugins.promoted_builds.conditions.*
println "RUNNING NIGHTLY PROMOTION GROOVY SCRIPT" //These are the jobs that are under the "Nightly" promotion processdef jobsToPromote = [Hudson.instance.getJob("Test_job")]
//Object for the nightly promotionPromotionProcess nightlyPromotion = new PromotionProcess(jobsToPromote[0].getParent(), "Nightly")
//Object for the manual approval of the nightly promotionManualCondition manualPromotion = new ManualCondition()
//Array for storing builds promoted to "Latest"def jobBuildsToPromote = []
//Get builds of Jobs promoted to "Latest" and store them in jobBuildsToPromote arrayjobsToPromote.each { job -> (job.getBuilds()).find { build -> (build.getActions(PromotedBuildAction)).find { action -> if(action.contains("Latest")) { jobBuildsToPromote.add(build) return true } } }}
manualPromotion.approve(jobBuildsToPromote[0], nightlyPromotion)
//Function for reading environment variablesdef getBuildVariable(String key){def config = new HashMap()def thr = Thread.currentThread()def build = thr?.executabledef envVarsMap = build.parent.builds[0].properties.get("envVars")
config.putAll(envVarsMap)return config.get(key)}
return