如何确保CircleCi忽略由CircleCi本身引起的对母版的推送?

时间:2019-02-06 03:15:48

标签: git continuous-integration circleci

CircleCi在将代码推送到母版时运行,但是CircleCi在称为Version Package Bump的运行脚本中推送自身。因此,在第一个构建之后,将运行第二个。但失败并显示以下消息:

  

在分支主服务器上您的分支是最新的'origin / master'。   没有要提交的内容,工作目录很干净,退出代码为1

如何确保CircleCi不会因自身的推动而再次启动?

jobs:
  build:
    docker:
      - image: circleci/node:8.10.0
    branches:
      only:
        - master
    steps:
      - add_ssh_keys
      - checkout
      - run:
          name: Keyscan DreamHost (HACK)
          command: ssh-keyscan -H HOST >> ~/.ssh/known_hosts
      - run:
          name: Install Dependencies
          command: npm install
      - run:
          name: Build App
          command: npm run build
      - run:
          name: Verion Package Bump
          command: |
            git config user.name "circleci"
            git config user.email "EMAIL"
            git add .
            git commit -m "[ci] Generated Build"
            npm version patch -m "[ci] Bumped version number to %s"
            git push origin master
            git push --tags
      - deploy:
          name: Publish to DreamHost
          command: scp -r build/* HOST:./DIRECTORY/

即使我将它包装在有条件的容器中,我仍然会看到相同的错误,并且两次构建都会发生:

if ! git diff-index --quiet HEAD --; then
    git config user.name "circleci"
    git config user.email "EMAIL"
    git add .
    git commit -m "[ci] Generated Build"
    npm version patch -m "[ci] Bumped version number to %s"
    git push origin master
    git push --tags
fi

1 个答案:

答案 0 :(得分:5)

在提交消息的任何位置添加[ci skip][skip ci]标签。

请参见https://circleci.com/docs/2.0/skip-build/

替换您的

git commit -m "[ci] Generated Build"

使用

git commit -m "[ci skip] Generated Build"

git commit -m "Generated Build [skip ci]"