golang-dy-back/Jenkinsfile
2025-10-28 19:37:28 +08:00

34 lines
814 B
Groovy

pipeline {
agent any
stages {
stage('Checkout') {
steps {
git url: 'http://47.95.203.241:3000/ReeseLin/golang-dy-back.git',
credentialsId: '932fcb89-1c39-4005-b664-15e862f09e20'
}
}
stage('Build Go Binary') {
steps {
sh '''
docker run --rm -v $PWD:/app -w /app golang:1.22-alpine \
sh -c "go mod tidy && go build -o go-dy ."
'''
}
}
stage('Build Docker Image') {
steps {
sh 'docker build -t go-dy:latest .'
}
}
stage('Deploy') {
steps {
sh 'docker run -d -p 8090:18080 --name go-dy go-dy:latest'
}
}
}
}