update jenksfiles

This commit is contained in:
Gregory Hendrickson
2023-06-08 14:23:09 -07:00
parent 1320abb91d
commit 78781dbc5c

59
Jenkinsfile vendored
View File

@@ -1,36 +1,39 @@
node {
def app
pipeline{
stage('Clone repository') {
/* Let's make sure we have the repository cloned to our workspace */
agent any
checkout scm
}
environment {
DOCKERHUB_CREDENTIALS=credentials('dockerhub-cred')
}
stage('Build image') {
/* This builds the actual image; synonymous to
* docker build on the command line */
stages {
app = docker.build("aisthanestha/docker-test-image")
}
stage('Build') {
stage('Test image') {
/* Ideally, we would run a test framework against our image.
* For this example, we're using a Volkswagen-type approach ;-) */
steps {
sh 'docker build -t aisthanestha/docker-test-image:latest .'
}
}
app.inside {
sh 'echo "Tests passed"'
}
}
stage('Login') {
steps {
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
}
}
stage('Push') {
steps {
sh 'docker push aisthanestha/docker-test-image:latest'
}
}
}
post {
always {
sh 'docker logout'
}
}
stage('Push image') {
/* Finally, we'll push the image with two tags:
* First, the incremental build number from Jenkins
* Second, the 'latest' tag.
* Pushing multiple tags is cheap, as all the layers are reused. */
docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') {
app.push("${env.BUILD_NUMBER}")
app.push("latest")
}
}
}