Update Jenkinsfile
This commit is contained in:
parent
c88a4347d7
commit
8c4738f12d
|
|
@ -3,6 +3,7 @@ pipeline {
|
|||
|
||||
environment {
|
||||
NODE_VERSION = '20.17.0'
|
||||
PR_NUMBER = "${env.CHANGE_ID}" // PR number comes from webhook payload
|
||||
}
|
||||
|
||||
stages {
|
||||
|
|
@ -32,6 +33,38 @@ pipeline {
|
|||
sh 'npm run build'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build and Push Docker Image') {
|
||||
when {
|
||||
expression { return env.CHANGE_ID != null } // Only run if it's a PR
|
||||
}
|
||||
steps {
|
||||
withCredentials([string(credentialsId: 'gh-pat', variable: 'GITHUB_PASS')]) {
|
||||
|
||||
// Docker login step
|
||||
sh '''
|
||||
echo "$GITHUB_PASS" | docker login ghcr.io -u "egelhaus" --password-stdin
|
||||
'''
|
||||
|
||||
// Set image tag dynamically based on the PR number
|
||||
sh '''
|
||||
IMAGE_TAG="ghcr.io/gitroomhq/postiz-app-pr:$PR_NUMBER"
|
||||
echo "IMAGE_TAG=$IMAGE_TAG" >> image.env
|
||||
'''
|
||||
|
||||
// Build Docker image
|
||||
sh '''
|
||||
source image.env
|
||||
docker build -f Dockerfile.dev -t $IMAGE_TAG .
|
||||
'''
|
||||
|
||||
// Push Docker image to GitHub Container Registry
|
||||
sh '''
|
||||
source image.env
|
||||
docker push $IMAGE_TAG
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
success {
|
||||
|
|
|
|||
Loading…
Reference in New Issue