【问题标题】:Openshift Jenkins pipelineOpenshift Jenkins 流水线
【发布时间】:2021-02-01 13:44:52
【问题描述】:

我正在寻找关于 openshift 上 Jenkins 管道下面使用的函数的解释。

  1. builds.untilEach(1)
  2. it.describe()
  3. echo "内部循环:${it}"
  4. return (it.object().status.phase == "Complete")
node {
    stage('build') {
        openshift.withCluster() {
            openshift.withProject() {
              echo "Using project: ${openshift.project()}"
              def builds = openshift.selector("bc", "front-end-build").related('builds')
              builds.describe()
              timeout(5) { 
               1. builds.untilEach(1) {
                2.    it.describe()
                 3.   echo "Inside loop: ${it}"
                   4. return (it.object().status.phase == "Complete")
                }
              }
            }
        }
    }
}

【问题讨论】:

  • 您可以添加更多上下文吗?你想用这个管道做什么?你能重新表述你的问题吗?
  • 以下几行是什么意思: builds.untilEach(1) { it.describe() echo "Inside loop: ${it}" return (it.object().status.phase == "完成")

标签: jenkins jenkins-pipeline openshift


【解决方案1】:

我将尝试概述您提到的这些行的含义:

  1. timeout(5) 这意味着这部分中描述的步骤({} 之间)需要在 5 分钟内完成,否则将被终止。如果以下任何操作花费的时间超过 5 分钟,此步骤将失败。

  2. builds.untilEach(1) 循环所有与上述选择器openshift.selector("bc", "front-end-build") 相关的构建。此循环期望至少返回一个构建。它循环构建并等待,直到闭包主体({} 之间)返回“true”。

  3. it.describe() 描述当前正在循环/等待的 Build 对象。

  4. echo "Inside loop: ${it}" 将 Build 对象写入标准输出。

  5. return (it.object().status.phase == "Complete")检查我们循环的Build是否完成并返回。

所以基本上,这个循环将等待与 BuildConfig front-end-build 相关的所有构建完成。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-29
    • 2022-09-26
    • 2017-12-21
    • 1970-01-01
    • 2021-10-07
    • 2018-11-24
    • 1970-01-01
    相关资源
    最近更新 更多