This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def LABEL_ID = "yourappname-${UUID.randomUUID().toString()}" | |
def BRANCH_NAME = "<Your branch name>" | |
def GIT_URL = "<Your git url>" | |
// Start Agent | |
node(LABEL_ID) { | |
stage('Checkout') { | |
doCheckout(BRANCH_NAME, GIT_URL) | |
} | |
stage('Build') { | |
... | |
} | |
stage('Tests') { | |
... | |
} | |
} | |
// Kill Agent | |
// Input Step | |
timeout(time: 15, unit: "MINUTES") { | |
input message: 'Do you want to approve the deploy in production?', ok: 'Yes' | |
} | |
// Start Agent Again | |
node(LABEL_ID) { | |
doCheckout(BRANCH_NAME, GIT_URL) | |
stage('Deploy') { | |
... | |
} | |
} | |
def doCheckout(branchName, gitUrl){ | |
checkout([$class: 'GitSCM', | |
branches: [[name: branchName]], | |
doGenerateSubmoduleConfigurations: false, | |
extensions:[[$class: 'CloneOption', noTags: true, reference: '', shallow: true]], | |
userRemoteConfigs: [[credentialsId: '<Your credentials id>', url: gitUrl]]]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment