Try fixing Jenkins.

This commit is contained in:
emil28092005
2026-01-17 22:40:55 +00:00
parent 1e29b2e624
commit ce46878054
2 changed files with 51 additions and 43 deletions
Vendored
+51 -42
View File
@@ -1,45 +1,54 @@
pipeline{
agent { label 'docker' }
options {
skipDefaultCheckout()
}
environment {
PROJECT_DIR = "/opt/shagram/shagram"
IMAGE_NAME = "shagram"
}
stages{
stage('Checkout') {
steps {
dir(env.PROJECT_DIR) {
deleteDir()
git url: 'https://github.com/emil28092005/shagram.git', branch: 'main'
}
}
}
stage('Build') {
steps {
dir(env.PROJECT_DIR) {
echo 'Building shagram...'
sh 'docker build -t ${IMAGE_NAME}:${GIT_COMMIT} .'
pipeline {
agent { label 'docker' }
options { skipDefaultCheckout() }
}
}
}
stage('Test') {
steps {
echo 'Testing...'
sh 'docker run --rm ${IMAGE_NAME}:${GIT_COMMIT} sqlite3 --version'
}
}
stage('Deploy') {
steps {
dir("${PROJECT_DIR}/deploy/shagram") {
echo 'Deploying...'
sh 'printf "APP_IMAGE=%s\\n" "${IMAGE_NAME}:${GIT_COMMIT}" > .env'
sh 'docker compose up -d'
sh 'docker compose ps'
}
}
environment {
IMAGE_NAME = "shagram"
DEPLOY_DIR = "/opt/shagram/shagram/deploy/shagram"
COMPOSE_FILE = "/opt/shagram/shagram/deploy/shagram/compose.yaml"
}
stages {
stage('Checkout') {
steps {
script {
deleteDir()
def scmVars = git url: 'https://github.com/emil28092005/shagram.git', branch: 'cicd-fix'
env.IMAGE_TAG = scmVars.GIT_COMMIT.take(7)
}
}
}
}
stage('Build') {
steps {
sh 'docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .'
}
}
stage('Test') {
steps {
sh 'docker run --rm ${IMAGE_NAME}:${IMAGE_TAG} sqlite3 --version'
}
}
stage('Deploy') {
steps {
sh '''
set -e
printf "APP_IMAGE=%s\\n" "${IMAGE_NAME}:${IMAGE_TAG}" > "${DEPLOY_DIR}/.env"
docker compose \
--project-directory "${DEPLOY_DIR}" \
-f "${COMPOSE_FILE}" \
up -d --build
docker compose \
--project-directory "${DEPLOY_DIR}" \
-f "${COMPOSE_FILE}" \
ps
'''
}
}
}
}
-1
View File
@@ -11,7 +11,6 @@ services:
jenkins-agent-docker:
image: jenkins/inbound-agent:latest-jdk17
container_name: jenkins-agent-docker
user: "0:0"
environment:
- JENKINS_URL=http://jenkins-controller:8080
- JENKINS_AGENT_NAME=docker-agent