美文网首页
gitlab-cicd

gitlab-cicd

作者: w_dll | 来源:发表于2022-08-01 11:57 被阅读0次

一 首先需要制作镜像



本地打包好 上传到镜像仓库

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

相关文章

  • gitlab-cicd

    一 首先需要制作镜像 本地打包好 上传到镜像仓库 二 pipline文件

  • gitlab-CICD共享runner基本配置

    gitlab-CICD共享runner基本配置 使用docker部署runner 多个项目使用共享runner 部...

  • 部署自动打包环境

    部署自动打包环境 概述 基于Gitlab-CICD配置的自动打包环境。 在Gitlab上创建Tag时,会执行包含D...

  • gitlab-cicd(持续化集成)

    ### 在需要部署的服务器中首先需要安装gitlab-runner - 下载二进制文件 # Linux x86-6...

网友评论

      本文标题:gitlab-cicd

      本文链接:https://www.haomeiwen.com/subject/jqhrwrtx.html