Forked from keliix06/Simple Jenkinsfile to deploy an Angular app to AWS
Created
May 16, 2023 17:52
-
-
Save ryanpadilha/7ec1bb9449e731ccb1e961a32ff0e292 to your computer and use it in GitHub Desktop.
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 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