Unverified Commit 23afb98b authored by nasirhm's avatar nasirhm

🔧 👷

Signed-off-by: 's avatarnasirhm <nasirhussainm14@gmail.com>
parent 07e5b5b2
pipeline { pipeline {
agent any agent any
stages { stages {
stage('Docker Build and Tag') { stage('Docker Build and Tag') {
steps { steps {
sh 'docker build -t my-application:latest .' sh 'docker build -t my-application:latest .'
sh 'docker tag my-application my-application:$BUILD_NUMBER' sh 'docker tag my-application my-application:$BUILD_NUMBER'
} }
} }
stage('Run Docker Container on Jenkins Agent') { stage('Check for an Existing Container Running'){
steps {
if(sh(docker ps | grep my-application)){
sh 'docker kill my-application'
sh 'docker rm my-application'
}
}
}
stage('Run Docker Container on Jenkins Agent') {
steps { steps {
sh 'docker run -d -p 80:80 my-application' sh 'docker run -d --name my-application -p 80:80 my-application'
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment