持续集成与持续部署(六)01-CircleCI——使用简介-持续集成工具 & config.yml完整配置

持续集成与持续部署(六)01-CircleCI——使用简介-持续集成工具 & config.yml完整配置

CircleCI

使用简介

  1. 注册 CircleCI

    打开 CircleCI 官方网站,使用您的GitHub帐户登录。

在这里插入图片描述

进行授权:

在这里插入图片描述

  1. 启动存储库

检查要在 CircleCI 上管理的存储库的开关按钮。

在这里插入图片描述

  1. 编写 config.yml

    version: 2
    jobs:
      build:
        docker:
          ...
        branches:
          ...
        steps:
          ...
    		environment:
    			...
    

    官方参考文档:https://circleci.com/docs/2.0/configuration-reference/#version

    config.yml配置

    来看一个完事版的配置

    version: 2
    jobs:
      build:
        docker:
          - image: ubuntu:14.04
    
          - image: mongo:2.6.8
            command: [mongod, --smallfiles]
    
          - image: postgres:9.4.1
            # some containers require setting environment variables
            environment:
              POSTGRES_USER: root
    
          - image: redis@sha256:54057dd7e125ca41afe526a877e8bd35ec2cdd33b9217e022ed37bdcf7d09673
    
          - image: rabbitmq:3.5.4
    
        environment:
          TEST_REPORTS: /tmp/test-reports
    
        working_directory: ~/my-project
    
        steps:
          - checkout
    
          - run:
              command: echo 127.0.0.1 devhost | sudo tee -a /etc/hosts
    
          # Create Postgres users and database
          # Note the YAML heredoc '|' for nicer formatting
          - run: |
              sudo -u root createuser -h localhost --superuser ubuntu &&
              sudo createdb -h localhost test_db
    
          - restore_cache:
              keys:
                - v1-my-project-{{ checksum "project.clj" }}
                - v1-my-project-
    
          - run:
              environment:
                SSH_TARGET: "localhost"
                TEST_ENV: "linux"
              command: |
                set -xu
                mkdir -p ${TEST_REPORTS}
                run-tests.sh
                cp out/tests/*.xml ${TEST_REPORTS}
    
          - run: |
              set -xu
              mkdir -p /tmp/artifacts
              create_jars.sh ${CIRCLE_BUILD_NUM}
              cp *.jar /tmp/artifacts
    
          - save_cache:
              key: v1-my-project-{{ checksum "project.clj" }}
              paths:
                - ~/.m2
    
          # Save artifacts
          - store_artifacts:
              path: /tmp/artifacts
              destination: build
    
          # Upload test results
          - store_test_results:
              path: /tmp/test-reports
    
      deploy-stage:
        docker:
          - image: ubuntu:14.04
        working_directory: /tmp/my-project
        steps:
          - run:
              name: Deploy if tests pass and branch is Staging
              command: ansible-playbook site.yml -i staging
    
      deploy-prod:
        docker:
          - image: ubuntu:14.04
        working_directory: /tmp/my-project
        steps:
          - run:
              name: Deploy if tests pass and branch is Master
              command: ansible-playbook site.yml -i production
    
    workflows:
      version: 2
      build-deploy:
        jobs:
          - build:
              filters:
                branches:
                  ignore:
                    - develop
                    - /feature-.*/
          - deploy-stage:
              requires:
                - build
              filters:
                branches:
                  only: staging
          - deploy-prod:
              requires:
                - build
              filters:
                branches:
                  only: master
    
  2. 设置/查看任务

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值