Title: Gitlab JC/CD 第二篇

Categories: git lab

Description: spring-cloud java cicd gitlab

Keywords: spring git lab java

just now

# cache 这个参数用于定义全局那些文件将被 cache 到下一个  stages
# 调试开启
before_script:
 - pwd
 - env
 ##
 ## Assuming you created the SSH_KNOWN_HOSTS variable, uncomment the
 ## follo wing two lines.
 ##
 - mkdir -p /root/.ssh/
 - chmod  700 /root/.ssh/
 - echo -e "StrictHostKeyChecking no \nUserKnownHostsFile /dev/null" > ~/.ssh/config
cache:
  key: $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHA
  paths:
    - build/
    - /data/repo
stages:
  - build-jar
  - build-release
  - build-dev
variables:
  DOCKER_DRIVER: overlay2
  MAVEN_OPTS: "-Dmaven.repo.local=/data/repo"
  CI_DEBUG_TRACE: "true"
build-Java:
  image: "registry.cn-hangzhou.aliyuncs.com/emos_prod/centos7-jdk8-maven3-git-1.8:latest"
  stage: build-jar
  script:
    - chmod u+x ./maven-build-all.sh
    - ./maven-build-all.sh
    - ls -a build/
  tags:
    - build_dev

release-jar-release:
  image: "registry.cn-hangzhou.aliyuncs.com/emos_prod/centos7-jdk8-maven3-git-1.8:latest"
  stage: build-release
  script:
    - git clone http://$GITLAB_USER:$GITLAB_PASS@gitlab-cicd.com/release/build-space.git
    - cd build-space && rm -rf * && cp -r ../build/* .
    - git config --global user.name "root"
    - git config --global user.email "[email protected]"
    - git add --all .
    - git commit -m "Gitlab CI Auto Builder master"
    - git push --force --quiet http://$GITLAB_USER:$GITLAB_PASSgitlab-cicd.com/release/build-space.git master:master
  tags:
    - build_dev
  only:
    - master

release-jar-dev:
  image: "registry.cn-hangzhou.aliyuncs.com/emos_prod/centos7-jdk8-maven3-git-1.8:latest"
  stage: build-dev
  script:
    - git clone http://$GITLAB_USER:$GITLAB_PASS@gitlab-cicd.com/dev/build-space.git
    - cd build-space && rm -rf * && cp -r ../build/* .
    - git config user.name "root"
    - git config user.email "[email protected]"
    - git add --all .
    - git commit -m "Gitlab CI Auto Builder dev"
    - git push --force --quiet http://$GITLAB_USER:[email protected]/dev/build-space.git dev:dev
  tags:
    - build_dev
  only:
    - dev

转载请注明出处,本文采用 CC4.0 协议授权