How to repeat a stage in Jenkins Workflow

TechCrunch picture TechCrunch · Oct 2, 2015 · Viewed 9.5k times · Source

I'm trying to use Jenkins on Cloudbees to automate deployment of my software. I setup my workflow as following.

Jenkins Workflow

There may be times I want to redeploy. (assuming that stage takes a manual input parameter). How do I do that in workflow ? Here is my Groovy script.

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
}

I tried using Job Chaining using Build Pipeline instead of Workflow so that I can repeat stages, but thats another story with too many jobs.

Answer

gogstad picture gogstad · Dec 6, 2016

This is only possible in the enterprise version of Jenkins. As @jesse-glick pointed out, you have the Checkpoint Plugin available there, see the documentation.

There's is currently no plan to support this feature in the OSS-version according to CloudBees. See this issue: JENKINS-33846