其他分享
首页 > 其他分享> > CICD--.gitlab-ci.yml

CICD--.gitlab-ci.yml

作者:互联网

before_script:
  - vserion=0.1.1
stages:
  - install_go
  - build_rule

install_go:
  stage: install_go
  before_script:
    - echo "Check the docker version, then build merge-rule docker images"
    - docker --version
    - docker build -f Dockerfile -t merge-rule .
    - signal=$?
    - >
      if (($signal==0));then
        echo "docker images build successful"
      fi
  script:
    - docker run -it -d --name merge-rule merge-rule
    - temp=$?
    - >
      if (($temp==0));then
          echo "docker run successful"
          docker cp merge-rule:/data-merge-rule/merge-rule /tmp/
          ok=$?
          if (($ok==0));then
            echo "file copy successful"
          fi
      fi
  allow_failure: false
  retry: 1
  only:
    - master

build_rule:
  stage: build_rule
  when: on_success
  script:
    - file="/tmp/merge-rule"
    - >
      if [-f $file]; then
        echo "merge-rule file does not exist"
      else
        curl -H 'X-JFrog-Art-Api:AKCp5e3ox3gXzFKed6wsJfehAanGYkVn7PM2gxvh2xVupE4RE7qgqBKk1T6kdHkDiUuCjbFLg' -T /tmp/merge-rule 'https://af-biz.qianxin-inc.cn:443/artifactory/skyeye-generic/arp/kyeye-generic/arp/soar-platform/merge-rule-'$vserion''
      fi
    - sleep 15
    - docker stop `docker ps -a| grep merge-rule | awk '{print $1}' `
    - docker rm  `docker ps -a| grep merge-rule | awk '{print $1}' `
  allow_failure: false
  retry: 1
  only:
    - tags

标签:ci,CICD,rule,echo,merge,--.,build,file,docker
来源: https://www.cnblogs.com/xj9912/p/16533202.html