提交 3b9143da 编写于 作者: LinuxSuRen's avatar LinuxSuRen

Fix the pipeline script

上级 8157088c
......@@ -3,24 +3,42 @@ pipeline {
label "golang"
}
environment {
IMAGE_TAG = ""
}
stages{
stage("build") {
steps {
sh 'make build'
container('golang'){
sh '''
CGO_ENABLED=0 GOOS=linux go build -ldflags "-w -s" -a -installsuffix cgo -o bin/wechat-backend
upx bin/wechat-backend
'''
}
}
}
stage("image") {
steps {
sh 'make image'
container('golang'){
sh '''
IMAGE_TAG=$(git rev-parse --short HEAD)
docker build -t surenpi/jenkins-wechat:$IMAGE_TAG .
docker push surenpi/jenkins-wechat:$IMAGE_TAG
'''
}
}
}
stage("push-image") {
environment {
DOCKER_CREDS = credentials('docker-surenpi')
}
steps {
withCredentials([usernamePassword(credentialsId: '', passwordVariable: 'passwd', usernameVariable: 'user')]) {
container('golang') {
sh '''
docker login -u $user -p $passwd
docker login -u $DOCKER_CREDS_USR -p $DOCKER_CREDS_PSW
make push-image
docker logout
'''
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册