image: alpine:latest
before_script:
stages:
- build
- scp
- deploy
- ftp
cache:
paths:
- build/
variables:
FTP_HOST: "ftp://150.138.84.36:21/ygy/hujiahuan/sursen-admin/"
SURSEN: "[email protected]"
SERVER_HOST: "10.0.27.45:/root/v2.2_arv/ARV_Install_Package/SurSecAdmin/"
FILEPATH: "/root/v2.2_arv/ARV_Install_Package/SurSecAdmin/"
build_job:
image: golang:1.18
stage: build
script:
- echo "This is the first build job"
- ls
- cd server
- go env -w GOPROXY=https://goproxy.cn,direct
- go mod tidy
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $SURSEN main.go
- echo "success"
artifacts:
name: $SURSEN
paths:
- build/$SURSEN
expire_in: 1 week
tags:
- sursen
scp_job:
stage: scp
script:
- echo "This is the second scp job"
- ls
- cd build
- ls
- apk add openssh-client
- chmod -R 600 id_rsa
- scp -o StrictHostKeyChecking=no -i id_rsa $SURSEN "$USERNAME"@$SERVER_HOST
- echo "scp success"
tags:
- sursen
deploy_job:
stage: deploy
script:
- echo "This is the third deploy job"
- ls
- cd build
- ls
- apk add openssh-client
- chmod -R 600 id_rsa
- ssh -T -o StrictHostKeyChecking=no -i id_rsa [email protected] "cd $FILEPATH; ./deploy.sh $SURSEN"
- echo "deploy success"
tags:
- sursen
ftp_job:
stage: ftp
script:
- echo "This is the fourth deploy job"
- ls
- cd build
- ls
- apk add --no-cache curl
- curl -m 30 --retry 5 -T $SURSEN -u "$FTP_USERNAME":"$FTP_PASSWORD" $FTP_HOST
- echo "ftp success"
tags:
- sursen