Skip to content

Instantly share code, notes, and snippets.

@VireshDoshi
Last active February 26, 2018 09:37
Show Gist options
  • Save VireshDoshi/2bbeef8c5b24021e993b4334d3b8ce80 to your computer and use it in GitHub Desktop.
Save VireshDoshi/2bbeef8c5b24021e993b4334d3b8ce80 to your computer and use it in GitHub Desktop.
Jenkins Pipeline script to build the AMI image and push to AWS
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