Last active
August 26, 2024 14:41
-
-
Save VireshDoshi/b2f78c3d7137196a6e975bb819761211 to your computer and use it in GitHub Desktop.
Deploy to AWS Jenkinsfile
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('pre-setup') { | |
steps { | |
sh 'echo "setup actions go here"' | |
deleteDir() | |
} | |
} | |
stage('AWS Deployment') { | |
steps { | |
withCredentials([ | |
usernamePassword(credentialsId: 'AWS_ACCESS_ID', passwordVariable: 'AWS_SECRET', usernameVariable: 'AWS_KEY'), | |
usernamePassword(credentialsId: 'GIT_ACCESS_ID', passwordVariable: 'REPO_PASS', usernameVariable: 'REPO_USER'), | |
]) { | |
sh 'rm -rf node-app-terraform' | |
sh 'git clone https://github.com/vireshdoshi/node-app-terraform.git .' | |
sh ''' | |
terraform init | |
terraform apply -auto-approve -var access_key=${AWS_KEY} -var secret_key=${AWS_SECRET} | |
git add terraform.tfstate | |
git -c user.name="Viresh Doshi" -c user.email="[email protected]" commit -m "terraform state update from Jenkins" | |
git push https://${REPO_USER}:${REPO_PASS}@github.com/vireshdoshi/node-app-terraform.git master | |
terraform output | |
''' | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment