Last active
February 26, 2018 09:37
-
-
Save VireshDoshi/2bbeef8c5b24021e993b4334d3b8ce80 to your computer and use it in GitHub Desktop.
Jenkins Pipeline script to build the AMI image and push to AWS
This file contains hidden or 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
pipeline { | |
agent { | |
docker { | |
image 'vireshdoshi/jen-build-node-app-aws:latest' | |
} | |
} | |
stages { | |
stage('Checkout and Build') { | |
steps { | |
sh 'git clone https://github.com/VireshDoshi/node-app .' | |
sh 'npm install' | |
} | |
} | |
stage('Create Packer AMI') { | |
steps { | |
withCredentials([ | |
usernamePassword(credentialsId: 'AWS_ACCESS_ID', passwordVariable: 'AWS_SECRET', usernameVariable: 'AWS_KEY') | |
]) { | |
sh 'packer build -var aws_access_key=${AWS_KEY} -var aws_secret_key=${AWS_SECRET} packer/packer.json' | |
} | |
} | |
} | |
} | |
post { | |
always { | |
cleanWs() | |
} | |
} | |
environment { | |
npm_config_cache = 'npm-cache-2' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment