简体   繁体   English

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

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

I know I can use scm polling via a Jenkins RTC plugin, I'm just wondering if there's an example of how to do this via the groovy script for the pipeline plugin?我知道我可以通过 Jenkins RTC 插件使用 scm 轮询,我只是想知道是否有一个示例说明如何通过管道插件的 groovy 脚本执行此操作?

For example:例如:

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

Something like above but instead of git, you use rtc toolkit with prod url and specify a stream or a workspace... Cannot find an example anywhere and not sure how to go about implementing it via api (or if that's even possible?)类似上面的东西,但不是 git,而是使用带有 prod url 的 rtc 工具包并指定流或工作区......在任何地方都找不到示例,并且不确定如何通过 api 实现它(或者如果这可能?)

Actually the snippet generator is a bit misleading in that it does not generate all that you need.实际上,代码段生成器有点误导,因为它不会生成您需要的所有内容。 For example, based on what was generated I used this in the pipeline:例如,根据生成的内容,我在管道中使用了它:

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

If you use it as is you will get this exception:如果你按原样使用它,你会得到这个例外:

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)

The syntax that you require is this:您需要的语法是这样的:

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

Team concert expects things to be wrapped in a 'buildType'.团队音乐会期望将事物包装在“buildType”中。 I found this in a forum answer on jazz.net, have not seen it documented anywhere else.我在 jazz.net 上的论坛回答中找到了这个,在其他任何地方都没有看到它的记录。

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

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

相关问题 如何将Team Foundation Server SCM插件与Jenkins Pipeline groovy脚本一起使用? - How can I use the Team Foundation Server SCM plugin with a Jenkins Pipeline groovy script? 如何通过Jenkins Pipeline插件中的groovy脚本访问全局环境 - How to access global environment through groovy script in Jenkins Pipeline Plugin 如何在 Jenkins 管道脚本中使用 shell 脚本变量作为 groovy 变量 - How to use shell script variable as groovy variable in Jenkins pipeline script 使用Jenkins Groovy管道脚本中的ci-game - Use ci-game from Jenkins groovy pipeline script 如何在Jenkins声明性管道中导入的groovy脚本中使用@Library? - How to use @Library in an imported groovy script in Jenkins declarative pipeline? 如何使用Groovy和Kubernetes插件从Jenkins Pipeline运行Kafka? - How to run Kafka from Jenkins Pipeline using Groovy and Kubernetes plugin? 如何从Jenkins Pipeline Groovy脚本访问收集的工件? - How to access collected artifacts from Jenkins pipeline groovy script? 如何从groovy映射脚本调用参数到Jenkins Pipeline - how to call parameters from groovy map script to Jenkins Pipeline 如何从 jenkins 管道 groovy 脚本中的 curl 获取 json 列表 - How to get a json list from the curl in jenkins pipeline groovy script 如何从Jenkins 2 Pipeline Groovy脚本中取消p4 - How to p4 unshelve from Jenkins 2 pipeline groovy script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM