首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >阶段阶段的Jenkinsfile条件

阶段阶段的Jenkinsfile条件
EN

Stack Overflow用户
提问于 2017-05-12 17:48:05
回答 1查看 544关注 0票数 2

是否可以在Jenkins文件的阶段阶段定义几个条件??

让我解释一下我的问题:只有在条件有效的情况下,我才想在Jenkins管道中使用publishHtml:

代码语言:javascript
复制
        stage(Documentation)
       {
        agent any
        steps 
        {
         sh"./documents.sh "     //This generate the documentation of several modules

         if(firstModule) { //Is it possible to publishHTML only if documentation of this module was generated???

             publishHTML (target: [
              allowMissing: false,
              alwaysLinkToLastBuild: false,
              keepAll: true,
              reportDir: "${env.WORKSPACE}/firstModule//html",
              reportFiles: 'index.html',
              reportName: "Fist Module Documentation"
            ])

         }

         if(secondModule) { //Is it possible to publishHTML only if documentation of this module was generated???                            
         publishHTML (target: [
              allowMissing: false,
              alwaysLinkToLastBuild: false,
              keepAll: true,
              reportDir: "${env.WORKSPACE}/secondModule/html",
              reportFiles: 'index.html',
              reportName: "Second Modul Documentation"
            ])
         }
     }

我不知道firstModule是建不造.这就是我想知道的。

我不想创建不同的阶段,而只是在jenkins视图中看到一个“文档”。

谢谢你的建议。

普里斯科

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-12 23:03:34

听起来,只有在存在firstModule的情况下,才需要为"${env.WORKSPACE}/firstModule/html/index.html发布文档。

而不是:

代码语言:javascript
复制
if(firstModule) {

尝试:

代码语言:javascript
复制
script {
   if (fileExists("${env.WORKSPACE}/firstModule/html/index.html")) {
     # publishHTML and whatnot
   }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43943707

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档