circleci#无法解析YAML#此处不允许使用映射值

时间:2019-03-02 13:19:00

标签: android continuous-integration circleci-2.0

我需要在CriclCi中构建我的Android应用。我刚刚发现了一个provided sample,如下所示:

version: 2
jobs:
  build:
    working_directory: ~/code
    docker:
      - image: circleci/android:api-25-alpha
    environment:
      JVM_OPTS: -Xmx3200m
    steps:
      - checkout
      - restore_cache:
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
#      - run:
#         name: Chmod permissions #if permission for Gradlew Dependencies fail, use this.
#         command: sudo chmod +x ./gradlew
      - run:
          name: Download Dependencies
          command: ./gradlew androidDependencies
      - save_cache:
          paths:
            - ~/.gradle
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
      - run:
          name: Run Tests
          command: ./gradlew lint test
      - store_artifacts: # for display in Artifacts: https://circleci.com/docs/2.0/artifacts/ 
          path: app/build/reports
          destination: reports
      - store_test_results: # for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
          path: app/build/test-results
      # See https://circleci.com/docs/2.0/deployment-integrations/ for deploy examples

但是,当我使用它时,CircleCi构建失败并抱怨:

#!/bin/bash -eo pipefail
./gradlew androidDependencies
/bin/bash: ./gradlew: Permission denied
Exited with code 126

结果,我添加了以下代码,然后重试:

  run:
         name: Chmod permissions
         command: sudo chmod +x ./gradlew

CCI建议使用此代码,但这一次它抱怨:

#!/bin/sh -eo pipefail
# Unable to parse YAML
# mapping values are not allowed here
#  in 'string', line 13, column 16:
#               - run:
#                    ^
# 
# -------
# Warning: This configuration was auto-generated to show you the message above.
# Don't rerun this job. Rerunning will have no effect.
false

我该如何解决?

1 个答案:

答案 0 :(得分:0)

我明白了,yml文件中的缩进应始终保持不变。 因此,run关键字应始终位于同一列中。