Skip to content

Commit

Permalink
add deployment pipeline at jenkins ayushiee#2
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhei2023 committed Jul 22, 2024
1 parent da00b10 commit 45212e0
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions pipelines/build.Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
pipeline {
agent {
label 'general'
}

label 'general'
}

triggers {
githubPush() // trigger the pipeline upon push event in github
Expand All @@ -14,9 +13,6 @@ pipeline {
}

environment {
// GIT_COMMIT = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
// TIMESTAMP = new Date().format("yyyyMMdd-HHmmss")

IMAGE_TAG = "v1.0.$BUILD_NUMBER"
IMAGE_BASE_NAME = "netflix-frontend-app"

Expand All @@ -36,22 +32,24 @@ pipeline {

stage('Build & Push') {
steps {
sh '''
IMAGE_FULL_NAME=$DOCKER_USERNAME/$IMAGE_BASE_NAME:$IMAGE_TAG

docker build -t $IMAGE_FULL_NAME .
docker push $IMAGE_FULL_NAME
'''
script {
def IMAGE_FULL_NAME = "${DOCKER_USERNAME}/${IMAGE_BASE_NAME}:${IMAGE_TAG}"
sh '''
docker build -t ${IMAGE_FULL_NAME} .
docker push ${IMAGE_FULL_NAME}
'''
env.IMAGE_FULL_NAME = IMAGE_FULL_NAME // set IMAGE_FULL_NAME to the environment variable for the next stage
}
}
}

stage('Trigger Deploy') {
steps {
build job: 'netflixDeploy', wait: false, parameters: [
string(name: 'SERVICE_NAME', value: "NetflixFrontend")
string(name: 'IMAGE_FULL_NAME_PARAM', value: "$IMAGE_FULL_NAME")
]
}
}
stage('Trigger Deploy') {
steps {
build job: 'netflixDeploy', wait: false, parameters: [
string(name: 'SERVICE_NAME', value: "NetflixFrontend"),
string(name: 'IMAGE_FULL_NAME_PARAM', value: "${env.IMAGE_FULL_NAME}")
]
}
}
}
}
}

0 comments on commit 45212e0

Please sign in to comment.