How do I dynamically trigger downstream builds in jenkins?

前端 未结 6 468
刺人心
刺人心 2020-12-14 20:34

We want to dynamically trigger integration tests in different downstream builds in jenkins. We have a parametrized integration test project that takes a test name as a param

6条回答
  •  醉梦人生
    2020-12-14 20:49

    This worked for me using "Execute system groovy script"

    import hudson.model.*
    
    def currentBuild = Thread.currentThread().executable
    
    def job = hudson.model.Hudson.instance.getJob("jobname")
    def params = new StringParameterValue('paramname', "somestring")  
    def paramsAction = new ParametersAction(params) 
    def cause = new hudson.model.Cause.UpstreamCause(currentBuild)
    def causeAction = new hudson.model.CauseAction(cause) 
    hudson.model.Hudson.instance.queue.schedule(job, 0, causeAction, paramsAction)
    

提交回复
热议问题