Testing Github webhook cicd.

This commit is contained in:
emil28092005
2026-01-18 05:52:24 +03:00
parent 5e6f526446
commit d115624d85
Vendored
+26 -20
View File
@@ -12,7 +12,6 @@ pipeline {
COMPOSE_FILE = "${WORKSPACE}/deploy/shagram/compose.yaml" COMPOSE_FILE = "${WORKSPACE}/deploy/shagram/compose.yaml"
} }
stages { stages {
stage('Checkout') { stage('Checkout') {
steps { steps {
@@ -25,6 +24,19 @@ pipeline {
} }
} }
stage('Detect branch') {
steps {
script {
env.GIT_BRANCH = sh(
script: "git name-rev --name-only --refs=refs/remotes/origin/* HEAD | sed 's#^remotes/##' | head -n1",
returnStdout: true
).trim()
echo "Detected branch: ${env.GIT_BRANCH}"
}
}
}
stage('Build') { stage('Build') {
steps { steps {
script { script {
@@ -40,33 +52,27 @@ pipeline {
stage('Test') { stage('Test') {
steps { steps {
sh ''' sh 'echo "Testing..."'
echo "Testing..."
'''
} }
} }
stage('Debug env') {
steps {
sh '''
echo "BRANCH_NAME=$BRANCH_NAME"
echo "GIT_BRANCH=$GIT_BRANCH"
git rev-parse --abbrev-ref HEAD || true
git rev-parse HEAD
'''
}
}
stage('Deploy') { stage('Deploy') {
when { when {
expression { env.GIT_BRANCH == 'origin/main' || env.GIT_BRANCH == 'main' } expression { env.GIT_BRANCH == 'origin/main' }
} }
steps { steps {
sh 'echo "deploying"' sh '''
sh 'touch /opt/shagram/TEST_WEBHOOK.txt' set -eux
}
}
mkdir -p "$DEPLOY_DIR"
cat > "$DEPLOY_DIR/.env" <<EOF
APP_IMAGE=$APP_IMAGE
EOF
docker compose -f "$COMPOSE_FILE" --project-directory "$DEPLOY_DIR" up -d --remove-orphans
docker compose -f "$COMPOSE_FILE" --project-directory "$DEPLOY_DIR" ps
'''
}
}
} }
} }