使用来自Jenkins groovy管道脚本的ci-game

时间:2016-12-15 08:40:38

标签: jenkins jenkins-plugins jenkins-pipeline

如何在Jenkins管道中将Jenkins Continuous Integration Game plugin(ci-game)用作代码(Jenkinsfile)作业?

3 个答案:

答案 0 :(得分:2)

不幸的是,ci-game插件还没有支持管道。 该插件未显示在Plugin Compatibility with Pipeline列表中。

此问题上已有一张开放票(JENKINS-42683)。

答案 1 :(得分:0)

单阶段的简单Jenkins声明式管道

pipeline {
    agent any 
    stages {
        stage('Stage 1') {
            steps {
                echo 'Hello world!' 
            }
        }
    }
}

具有多个Stage的简单Jenkins声明式管道

pipeline {
    agent any 
    stages {
        stage('Stage 1') {
            steps {
                echo 'Inside Stage 1' 
            }
        }
       stage('Stage 2') {
            steps {
                echo 'Inside Stage 2' 
            }
        }
    }
}

具有Post Actions的简单Jenkins声明式管道

pipeline {
    agent any 
    stages {
        stage('Stage 1') {
            steps {
                echo 'Inside Stage 1' 
            }
        post {
            failure {
                 script { echo 'failure Inside Stage 1'  }

            }
        success {
             script { echo 'failure Inside Stage 1'  }

        }
      }
    }
   stage('Stage 2') {
        steps {
            echo 'Inside Stage 2' 
        }
       post {
          failure {
              script { echo 'failure Inside Stage 2'  }

          }
          success {
              script { echo 'failure Inside Stage 1'  } 
          }
        }
    }
}

https://devopsdiagnosis.wixsite.com/tech/forum/jenkins/jenkins-pipeline

答案 2 :(得分:0)

最新的更新 1.26 似乎包含了 ci-game 的 DSL(参见 https://github.com/jenkinsci/ci-game-plugin/pull/19/commits/89e6c3e6ff11294418c2e741ebade5cfaa53ba1d )

我对其进行了测试,当您放置 ciGame() 时它似乎可以工作:

post {
  always {
    ciGame()
  }
}

然而,这位作者抱怨说它不起作用:

https://github.com/jenkinsci/ci-game-plugin/commit/89e6c3e6ff11294418c2e741ebade5cfaa53ba1d