【问题标题】:CircleCI environmental variables for HEROKU not being set properly causing GIT to fail未正确设置HEROKU的CircleCI环境变量导致GIT失败
【发布时间】:2018-06-16 15:17:31
【问题描述】:

我是 CircleCI 用户,我正在设置与 Heroku 的集成。

我想执行以下操作,并使用此 config.yml 文件通过与 dockerHub 以及从 CircleCI 门户页面到 Heroku 的集成来设置安全性。

问题在于 CircleCI 似乎不知道这些变量应该设置为什么,而只是回显。

${HEROKU_API_KEY} ${HEROKU_APP}

config.yml


版本:2 工作: 构建:

working_directory: ~/springboot_swagger_example-master-cassandra

docker:
  - image: circleci/openjdk:8-jdk-browsers

steps:

  - checkout

  - restore_cache:
      key: springboot_swagger_example-master-cassandra-{{ checksum "pom.xml" }}

  - run: mvn dependency:go-offline

  - save_cache:
      paths:
        - ~/.m2
      key: springboot_swagger_example-master-cassandra-{{ checksum "pom.xml" }}

  - type: add-ssh-keys
  - type: deploy
    name: "Deploy to Heroku"
    command: |
      if [ "${CIRCLE_BRANCH}" == "master" ]; then
        # Install Heroku fingerprint (this is heroku's own key, NOT any of your private or public keys)
        echo 'heroku.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAu8erSx6jh+8ztsfHwkNeFr/SZaSOcvoa8AyMpaerGIPZDB2TKNgNkMSYTLYGDK2ivsqXopo2W7dpQRBIVF80q9mNXy5tbt1WE04gbOBB26Wn2hF4bk3Tu+BNMFbvMjPbkVlC2hcFuQJdH4T2i/dtauyTpJbD/6ExHR9XYVhdhdMs0JsjP/Q5FNoWh2ff9YbZVpDQSTPvusUp4liLjPfa/i0t+2LpNCeWy8Y+V9gUlDWiyYwrfMVI0UwNCZZKHs1Unpc11/4HLitQRtvuk0Ot5qwwBxbmtvCDKZvj1aFBid71/mYdGRPYZMIxq1zgP1acePC1zfTG/lvuQ7d0Pe0kaw==' >> ~/.ssh/known_hosts
        # git push git@heroku.com:yourproject.git $CIRCLE_SHA1:refs/heads/master
        # Optional post-deploy commands
        # heroku run python manage.py migrate --app=my-heroku-project
      fi          

  - run: mvn package

  - run:
      name: Install Docker client
      command: |
        set -x
        VER="17.03.0-ce"
        curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
        tar -xz -C /tmp -f /tmp/docker-$VER.tgz
        mv /tmp/docker/* /usr/bin
  - run:
     name: Build Docker image
     command: docker build -t joethecoder2/spring-boot-web:$CIRCLE_SHA1 .

  - run:
      name: Push to DockerHub
      command: |
        docker login -u$DOCKERHUB_LOGIN -p$DOCKERHUB_PASSWORD
        docker push joethecoder2/spring-boot-web:$CIRCLE_SHA1

  - run:
      name: Setup Heroku
      command: |
        curl https://cli-assets.heroku.com/install-ubuntu.sh | sh
        chmod +x .circleci/setup-heroku.sh
        .circleci/setup-heroku.sh
  - run:
      name: Deploy to Heroku
      command: |
        mkdir app
        cd app/ 
        heroku create 
        # git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP.git master
        echo ${HEROKU_API_KEY}
        echo ${HEROKU_APP}
        git push https://heroku:${HEROKU_API_KEY}@git.heroku.com/${HEROKU_APP}.git master

  - store_test_results:
      path: target/surefire-reports

  - store_artifacts:
      path: target/spring-boot-web-0.0.1-SNAPSHOT.jar

问题在于 CircleCI 似乎不知道这些变量应该设置为什么,而只是回显。

${HEROKU_API_KEY} ${HEROKU_APP}

问题是为什么没有自动检测到这些设置?

【问题讨论】:

  • 您是否按照以下答案设置它们?

标签: docker github heroku circleci


【解决方案1】:

您需要为变量设置值:https://circleci.com/docs/2.0/env-vars/

它们被回显是因为你在回显它们。

echo ${HEROKU_API_KEY}
echo ${HEROKU_APP}

【讨论】:

    猜你喜欢
    • 2020-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-30
    • 2021-10-22
    • 1970-01-01
    • 1970-01-01
    • 2023-01-10
    相关资源
    最近更新 更多