Delete Job, created by Multibranch-Pipeline with jobDsl, when Branch is deleted

15 views
Skip to first unread message

robe...@web.de

unread,
May 2, 2017, 9:27:03 AM5/2/17
to jenkins...@googlegroups.com
Hello Jenkins users,
 
I have a Multibrach-Pipeline on my Jenkins which creates a job per branch.
branch1,branch2,branch3
 
These jobs create jobs again via the jobdsl-plugin in Jenkinsfile:
def createJob(jobFile) {
    def job = readFile (jobFile)
    jobDsl scriptText: job 
}
 
with jobFile is something like:
 
pipelineJob("branch1-job1") {
    environmentVariables {
        [...]
    }
    throttleConcurrentBuilds {
        [...]
    }  
    triggers {
        [...]
    }
    definition {
        cps {        
            script(readFileFromWorkspace('jenkins/jobPipelineDef.groovy'))
            sandbox()
        }
    }
}
 
Now my question: Is there a way to delete the pipelineJob(branch1-job1) if the job for branch1 is deleted by the Multibranch-Pipeline? Or do I have to manually determine the jobs and delete them via the jobDsl-plugin?
Platform: Jenkins ver. 2.46.2 with all plugins are up to date.
I have already asked the users at Stackoverflow, but unfortunately no answer received: http://stackoverflow.com/questions/43679852/jenkins-delete-job-created-by-multibranch-pipeline-with-jobdsl-when-branch- Is
 
Perhaps one of you can help me.
Thanks!
Robert
 
Reply all
Reply to author
Forward
0 new messages