Skip to content

Commit

Permalink
cas
Browse files Browse the repository at this point in the history
  • Loading branch information
sshresthadh committed Jul 4, 2024
1 parent 67980d1 commit 849e63c
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Jenkfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
pipeline {
agent any

environment {
DOCKERHUB_CREDENTIALS = credentials('dockerhub-credentials') // Jenkins credentials ID for Docker Hub
DOCKERHUB_REPO = 'samil88/frontend'
DOCKER_IMAGE_TAG = 'latest'
}

stages {
stage('Clone Repository') {
steps {
// Clone your repository
checkout scm
}
}

stage('Build Docker Image') {
steps {
script {
dockerImage = docker.build("${DOCKERHUB_REPO}:${DOCKER_IMAGE_TAG}")
}
}
}

stage('Push Docker Image') {
steps {
script {
docker.withRegistry('https://index.docker.io/v1/', 'dockerhub-credentials') {
dockerImage.push()
}
}
}
}
}

post {
always {
// Clean up Docker images to free up space
sh "docker rmi ${DOCKERHUB_REPO}:${DOCKER_IMAGE_TAG} || true"
}
}
}

0 comments on commit 849e63c

Please sign in to comment.