groovy - 如何在Jenkins Workflow中重复一个阶段

标签 groovy jenkins cloudbees continuous-deployment jenkins-workflow

我正在尝试在Cloudbees上使用Jenkins来自动部署软件。我按照以下步骤设置工作流程。

Jenkins Workflow

有时候我想重新部署。 (假设该阶段采用手动输入参数)。如何在工作流程中做到这一点?这是我的Groovy脚本。

def src = 'https://git.repo.url/proj.git'

stage 'Build'
node {
    env.JAVA_HOME="${tool name: 'Pre-Installed OpenJDK 8 (Latest) on DEV@Cloud nodes', type: 'hudson.model.JDK'}"
    sh 'javac -version'
    git credentialsId: 'abcdef', url: src
    sh 'ant -f build.xml proj.jar report'
}

stage 'Generate Release Version'
input message: 'Create Tar and Push to S3', ok: 'Generate Release'
node {
    // TODO
}

stage 'QA Approved'
input message: 'Enter a Tag Name to approve this build and tag in GIT', ok: 'Approve and Tag', parameters: [[$class: 'StringParameterDefinition', defaultValue: '', description: 'Eg: Sprint73', name: 'TAG_NAME']]
node {
    // TODO
}

stage 'DevOps - Ansible'
input message: 'Release to Production', ok: 'Release'
node {
    // TODO
}

我尝试使用“构建管道”而不是“工作流”来使用“工作链”,以便我可以重复执行各个阶段,但这是另一个有太多工作的故事。

最佳答案

这仅在企业版Jenkins中可行。正如@ jesse-glick指出的那样,您可以在此处使用Checkpoint插件,请参见documentation

根据CloudBees的说法,目前尚无计划在OSS版本中支持此功能。看到这个问题:JENKINS-33846

关于groovy - 如何在Jenkins Workflow中重复一个阶段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32900054/

相关文章:

grails - 定义自定义 grails 环境

git - 使用 Jenkins 管道将多个 git repos check out 到同一个作业中

java - 我启用了 rerunFailingTestsCount Surefire 功能。如何配置 Jenkins CI 以显示丰富的测试数据?

tomcat - 应用程序错误会停止 CloudBees 中的部署吗?

java - CloudBees 的 JMS 代理选项?

build - Cloudbees 上的 Redis 版本已过时?

java - 为什么系统找不到用Maven构建项目时指定的路径?

arrays - 如何从列表列表中获取列表

groovy - Geb配置

amazon-web-services - 在已承担角色的 EC2 实例上运行 ecr 命令需要哪些 iam 策略?