CircleCI мигрирует с v1 на 2 - локальный коммит Git не работает - PullRequest
0 голосов
/ 10 октября 2019

Я новичок в CircleCI. Я пытаюсь перенести CircleCI1.0 на 2.0, и у меня появилась эта ошибка:

     #!/bin/bash -eo pipefail
- if [ -n "$(git status --porcelain)" ]; then
        echo "*** Files have been updated. ***";
        git add *;
        git commit -m "latest voter info updates1";
        git push origin master;
        echo "*** Files committed to git. ***";
  else
        echo "*** Files have not changed. Nothing to commit and upload. ***";
  fi

/bin/bash: - : invalid option
Error: Exited with code 1
Step failed
Error: runner failed (exited with 101)
Task failed
Error: task failed

Вот мой конфигурационный файл версии 1:

machine:
  timezone:
    America/Los_Angeles
  python:
    version: 2.7.6

compile:
  override:
    - cd tools/scripts && ./compileJSON.py
    - cd ../../
    - if [ -n "$(git status --porcelain)" ]; then 
        echo "*** Files have been updated. ***";
        git add *;
        git commit -m "latest voter info updates";
        git push origin master;
        echo "*** Files committed to git. ***";
      else 
        echo "*** Files have not changed. Nothing to commit and upload. ***";
      fi

deployment:
  production:
    branch: master
    commands:
      - aws s3 cp json s3://foldername/json --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --recursive --include "*.*";

А вот перенесенная версияconfig:

 version: 2
jobs:
  build:
    environment:
      - BASH_ENV: ~/.bashrc
    docker:
      - image: circleci/python:2.7.14
    steps:
      - checkout
      - run:
          name: Build JSon File
          command: cd tools/scripts && ./compileJSON.py
      - run:
          name: Exit Folder
          command: cd ../../
      - run:
             name: install git
             command: sudo apt-get update && sudo apt-get upgrade && sudo apt-get install --no-install-recommends -y git
      - run:
          name: git commit --this command not running
          command: |
                  - if [ -n "$(git status --porcelain)" ]; then
                          echo "*** Files have been updated. ***";
                          git add *;
                          git commit -m "latest user info updates1";
                          git push origin master;
                          echo "*** Files committed to git. ***";
                    else
                          echo "*** Files have not changed. Nothing to commit and upload. ***";
                    fi
workflows:
  version: 2
  build_and_deploy:
    jobs:
      - deploy:
          filters:
            branches:
              only:
                - master

Проблема

- run:
              name: git commit --this command not running
              command: |
                      - if [ -n "$(git status --porcelain)" ]; then
                              echo "*** Files have been updated. ***";
                              git add *;
                              git commit -m "latest user info updates1";
                              git push origin master;
                              echo "*** Files committed to git. ***";
                        else
                              echo "*** Files have not changed. Nothing to commit and upload. ***";
                        fi

При выполнении вышеуказанной команды я получил вышеуказанную ошибку. Что не так с этой командой? Мне нужен локальный коммит, если что-то изменится в репо. Как этого добиться?

1 Ответ

1 голос
/ 11 октября 2019

Это то, что говорит ошибка. Для вашей новой конфигурации, в этом первом блоке if у вас есть тире (-) перед if, которого там быть не должно.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...