CircleCI将v1迁移到2本地Git commit不起作用

2024-05-06 07:54:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我是新来的。我正在尝试将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

当上述命令运行时,我得到了上述错误。这个命令怎么了?如果回购协议有任何变化,我需要本地提交。如何才能做到这一点


Tags: andtorunnamegitechomasterif