feat:更新Jenkins
This commit is contained in:
parent
99532b883d
commit
2a01abd023
21
Jenkinsfile
vendored
21
Jenkinsfile
vendored
@ -1,27 +1,32 @@
|
||||
pipeline {
|
||||
agent any
|
||||
environment {
|
||||
APP_HOME = "/opt/go-dy"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
git url: 'http://47.95.203.241:3000/ReeseLin/golang-dy-back', branch: 'main', credentialsId: 'GITEA_CREDENTIAL_ID'
|
||||
git url: 'http://47.95.203.241:3000/ReeseLin/golang-dy-back.git',
|
||||
credentialsId: '932fcb89-1c39-4005-b664-15e862f09e20'
|
||||
}
|
||||
}
|
||||
stage('Build Binary') {
|
||||
|
||||
stage('Build Go Binary') {
|
||||
steps {
|
||||
sh 'docker run --rm -v $APP_HOME:/app -w /app golang:1.22-alpine sh -c "go mod tidy && go build -o go-dy ."'
|
||||
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 $APP_HOME'
|
||||
sh 'docker build -t go-dy:latest .'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
sh 'docker stop go-dy || true && docker rm go-dy || true && docker run -d --name go-dy -p 8090:18080 go-dy:latest'
|
||||
sh 'docker run -d -p 8090:18080 --name go-dy go-dy:latest'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user