2015-05-20 62 views
0

我想寫有條件構建步驟jobdsl塊,如果條件爲真發送電子郵件, 它失敗對我來說,請協助改善下面的代碼(堆棧跟蹤下文)詹金斯JObDSL條件生成步驟發送郵件的問題

job { 
    name 'ci' 
    description 'Build and test the app.' 
    scm { 
     git { 
     remote { 
      github 'sheehan/job-dsl-playground' 
     } 
     } 
    } 
    steps { 
     gradle 'test' 
     conditionalSteps { 
     condition { 
      stringsMatch('${ENV,var="CHILD_BUILD"}', "true", false) 
     } 
     extendedEmail("[email protected]", "for Componets", 
         "Test Jira") 
    } 
    } 
     publishers { 
      archiveJunit 'build/test-results/**/*.xml' 
     } 
} 

堆棧跟蹤:

groovy.lang.MissingMethodException:方法的無簽名: javaposse.jobdsl.dsl.helpers.step.ConditionalStepsContext.extendedEmail() 適用於參數類型:(java中。 lang.String,java.l ang.String, java.lang.String中)的值:[[email protected],對成品的配件,測試 吉拉]在 javaposse.jobdsl.dsl.helpers.AbstractExtensibleContext.methodMissing(AbstractExtensibleContext.groovy:19) 在 javaposse.jobdsl.dsl.AbstractContext.invokeMethod(AbstractContext.groovy) 在 script14321438737322039521488 $ _run_closure1_closure3_closure7.doCall(script14321438737322039521488.groovy:17) 在 script14321438737322039521488 $ _run_closure1_closure3_closure7.doCall(script14321438737322039521488.groovy) 在 javaposse.jobdsl.dsl .ContextHelper.executeInContext(ContextHelper.groovy:14) at javaposse.jobdsl.dsl.ContextH elper $ executeInContext.call(未知 來源)在 javaposse.jobdsl.dsl.ContextHelper $ executeInContext.call(未知 來源)在 javaposse.jobdsl.dsl.helpers.step.StepContext.conditionalSteps(StepContext.groovy:554) 在 script14321438737322039521488 $ _run_closure1_closure3.doCall(script14321438737322039521488.groovy:13)在 script14321438737322039521488 $ _run_closure1_closure3.doCall(script14321438737322039521488.groovy) 在 javaposse.jobdsl.dsl.ContextHelper.executeInContext(ContextHelper.groovy:14) 在javaposse。 jobdsl.dsl.ContextHelper $ executeInContext.call(Unknown Source)at javaposse.jobdsl.dsl.ContextHelper $ exec uteInContext.call(未知 來源)在javaposse.jobdsl.dsl.Job.steps(Job.groovy:510)在 script14321438737322039521488 $ _run_closure1.doCall(script14321438737322039521488.groovy:11) 在javaposse.jobdsl.dsl.JobParent.job (JobParent.groovy:110)在 javaposse.jobdsl.dsl.JobParent.job(JobParent.groovy)在 javaposse.jobdsl.dsl.DslFactory $ job.callCurrent(來源不明)在 script14321438737322039521488.run(script14321438737322039521488.groovy: 1) 處 javaposse.jobdsl.dsl.DslScriptLoader.runDslEngineForParent(DslScriptLoader.java:72) 在 javaposse.jobdsl.dsl.DslScriptLoader $ runDslEngineForParent.call(未知 來源) com.sheehan.jobdsl.DslScriptExecutor.execute(DslScriptExecutor.groovy:31) at com.sheehan.jobdsl.ScriptExecutor $ execute.call(Unknown Source)at Ratpack $ _run_closure1_closure3_closure7.doCall(Ratpack.groovy:39)at ratpack .groovy.internal.ClosureInvoker.invoke(ClosureInvoker.java:65) at ratpack.groovy.handling.internal.ClosureBackedHandler.handle(ClosureBackedHandler。的java:42)

+0

你有沒有條件步驟插件安裝? https://wiki.jenkins-ci.org/display/JENKINS/Conditional+BuildStep+Plugin – KeepCalmAndCarryOn

+0

是的,也是我認爲這是更多的配置和獨立的真正的插件正在安裝或現在 – Stock

回答

0

我目前不能擴展電子郵件步驟測試這是一個出版商

具體根據documentation

出版商

塊包含的發佈商的列表。

擴展電子郵件插件

job { 
    publishers { 
     extendedEmail(String recipients = null, String subjectTemplate = null, 
         String contentTemplate = null) { 
      trigger(String triggerName, String subject = null, String body = null, 
        String recipientList = null, Boolean sendToDevelopers = null, 
        Boolean sendToRequester = null, includeCulprits = null, 
        Boolean sendToRecipientList = null) 
      trigger(Map args) 
      configure(Closure configureClosure) 
     } 
    } 
} 
+0

是的,但不是在條件構建步驟插件,當我使用條件構建步驟插件並添加電子郵件時,config.xml不會將其顯示爲發佈者,而是作爲構建步驟。我也厭倦了將它包裹在發佈者周圍,以檢查並且沒有幫助:( – Stock

+0

有https://wiki.jenkins-ci.org/display/JENKINS/Any+Build+Step+Plugin這是任何構建步驟使發佈步驟變成構建步驟,我認爲這不是在job-dsl中支持的,但是你可以使用配置塊來製作它,值得問一下這個工作 - dsl組https://groups.google.com/forum/ ?fromgroups#!topic/job-dsl-plugin/Ot7BCx4lz8M我看到你做了;) – KeepCalmAndCarryOn