Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ryanpadilha/7ec1bb9449e731ccb1e961a32ff0e292 to your computer and use it in GitHub Desktop.
Save ryanpadilha/7ec1bb9449e731ccb1e961a32ff0e292 to your computer and use it in GitHub Desktop.
def VERSION = "${env.BUILD_NUMBER}"
def DIST_ARCHIVE = "dist.${env.BUILD_NUMBER}"
def S3_BUCKET = 'angular-prod-deploy'
pipeline {
agent any
tools { nodejs "Angular Project" }
stages {
stage('NPM Install') {
steps {
script {
notifyBitbucket(buildStatus: 'INPROGRESS')
}
sh 'npm install --verbose -d'
}
}
stage('Test') {
steps {
sh 'npm run test'
}
}
stage('Build') {
steps {
sh 'npm run build'
}
}
stage('Archive') {
steps {
sh "cd dist && zip -r ../${DIST_ARCHIVE}.zip . && cd .."
archiveArtifacts artifacts: "${DIST_ARCHIVE}.zip", fingerprint: true
}
}
stage('Deploy') {
steps {
sh "aws s3 cp ${DIST_ARCHIVE}.zip s3://${S3_BUCKET}/${DIST_ARCHIVE}.zip --profile=default"
sh "aws deploy create-deployment --application-name Angular --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name angular-deployment-group --s3-location bucket=${S3_BUCKET},bundleType=zip,key=${DIST_ARCHIVE}.zip"
}
}
}
post {
always {
script {
currentBuild.result = currentBuild.result ?: 'SUCCESS'
notifyBitbucket()
if (currentBuild.result == 'SUCCESS') {
echo 'notify slack'
} else {
echo 'notify slack'
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment