gitlab-cicd
2022-08-01 本文已影响0人
w_dll
一 首先需要制作镜像

本地打包好 上传到镜像仓库
docker buildx build --platform linux/amd64 -t hub.ucloudadmin.com/uphost-sre/centos7-cicd:v0.1.1 .
docker push hub.ucloudadmin.com/uphost-sre/alpline-cicd:v0.1.5
二 pipline文件

image: hub.ucloudadmin.com/uphost-sre/alpline-cicd:v0.1.5
stages:
- build
- deploy
build-file:
stage: build
script:
- export ROOT_PATH=$(pwd)
- echo $CI_COMMIT_SHA && echo $ROOT_PATH && echo $ID_RSA
- cd $ROOT_PATH/windows
- if [ -f hybrid_cloud.7z ];then rm -f hybrid_cloud.7z;fi
- 7za a -t7z -r hybrid_cloud.7z steps2/ steps3/
- curl --upload-file hybrid_cloud.7z http://172.18.183.45:62121/files/hybrid_cloud.7z-$CI_COMMIT_SHA
- cd $ROOT_PATH/linux
- if [ -f hybrid_cloud.tar ];then rm -f hybrid_cloud.tar;fi
- tar -cvf hybrid_cloud.tar *
- curl --upload-file hybrid_cloud.tar http://172.18.183.45:62121/files/hybrid_cloud.tar-$CI_COMMIT_SHA
artifacts:
expire_in: '3 days'
when: on_success
tags:
- uaek-c1
only:
- master
.deploy:
before_script:
- if [ ! -d ~/.ssh ];then mkdir ~/.ssh;fi
- if [[ $ID_RSA ]];then echo "$ID_RSA" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa; fi
allow_failure: false
tags:
- uaek-c1
deploy--cn-wlcb-01:
extends: .deploy
stage: deploy
script:
- curl -o hybrid_cloud.7z http://172.18.183.45:62121/hybrid_cloud.7z-$CI_COMMIT_SHA
- curl -o hybrid_cloud.tar http://172.18.183.45:62121/hybrid_cloud.tar-$CI_COMMIT_SHA
- scp -o "StrictHostKeyChecking no" hybrid_cloud.7z root@10.77.12.238:/home/
- scp -o "StrictHostKeyChecking no" hybrid_cloud.tar root@10.77.12.238:/home/
when: manual
only:
- master
allow_failure: true