繁体   English   中英

如何使用 jenkins 管道 groovy 脚本中的 RTC 插件?

[英]How to use RTC plugin from jenkins pipeline groovy script?

我知道我可以通过 Jenkins RTC 插件使用 scm 轮询,我只是想知道是否有一个示例说明如何通过管道插件的 groovy 脚本执行此操作?

例如:

node{
   stage 'Checkout'
   git url: 'https://github.com/whatever/myrepo.git'
 ...
 }

类似上面的东西,但不是 git,而是使用带有 prod url 的 rtc 工具包并指定流或工作区......在任何地方都找不到示例,并且不确定如何通过 api 实现它(或者如果这可能?)

实际上,代码段生成器有点误导,因为它不会生成您需要的所有内容。 例如,根据生成的内容,我在管道中使用了它:

node {
    teamconcert([buildDefinition: 'TestStream', value: 'buildDefinition'])
}

如果你按原样使用它,你会得到这个例外:

RTC : checkout...
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.lang.NullPointerException
    at com.ibm.team.build.internal.hjplugin.RTCScm.checkout(RTCScm.java:1948)
    atorg.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:109)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:83)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:73)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:52)
    at hudson.security.ACL.impersonate(ACL.java:221)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

您需要的语法是这样的:

node {
    teamconcert([
        buildType: [
            buildDefinition: 'TestStream',
            value: 'buildDefinition'
       ]
    ])
}

团队音乐会期望将事物包装在“buildType”中。 我在 jazz.net 上的论坛回答中找到了这个,在其他任何地方都没有看到它的记录。

管道插件中有一个片段代码生成器,我花了一段时间才找到它,但它会为任何 Jenkins 任务生成常规代码... Rtc 列在 teamconcert: Team Concert 下,只需向下滚动到底部并勾选代码段生成器复选框!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM