I am pretty new to jenkins and trying to figure out the best way to accomplish rollbacks. Currently this is my pipeline:
- Obtain a webhook from beanstalk (git versioning)
- Build the project
- Obtain the build artifact and deploy to Azure
This is working great - the last thing I would like to solve is being able to rollback the project to a specific build.
When I do a "replay" however, it doesn't grab the actual commit the build ran on - it grabs the current commit in the repo. So it doesn't build the project from the commit it originally ran on - but the latest commit in the repo.
pipeline {
agent any
stages {
stage('Install Dependenciess') {
steps {
bat'npm install'
}
}
stage('Build the Project') {
steps {
bat'npm run build'
}
}
stage('Deploy to Azure Prod') {
when {
environment name: 'REPOSITORY_BRANCH', value: 'master'
beforeAgent true
}
steps {
timeout(time:5, unit: 'DAYS') {
input message: 'Approve Deployment?'
}
azureWebAppPublish azureCredentialsId: env.AZURE_CRED_ID,
resourceGroup: env.RES_GROUP,
appName: env.WEB_APP,
filePath: "**/*.*",
sourceDirectory: "build"
}
}
stage('Deploy to Azure Development') {
when {
environment name: 'REPOSITORY_BRANCH', value: 'development'
beforeAgent true
}
steps {
azureWebAppPublish azureCredentialsId: env.AZURE_CRED_ID,
resourceGroup: env.RES_GROUP,
appName: env.WEB_APP,
filePath: "**/*.*",
sourceDirectory: "build"
}
}
}
post {
always {
archiveArtifacts artifacts: "build/**/*.*", onlyIfSuccessful: true
cleanWs()
}
success {
mail bcc: '', body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "ERROR CI: Project name -> ${env.JOB_NAME}", to: "";
}
}
}
I looked into storing builds over in Azure Blob - but if I have to rollback I am unsure how I would set up a process to go grab those old artifacts to re-deploy to Azure. Bear in mind - our company will have dozens of projects running on this same build process.
– Justin H Jul 12 '19 at 22:13