2017-07-27 105 views
1

我試圖提供Gradle和Heroku的連續部署,但由於某些原因,部署步驟未運行。CircleCI + Gradle + Heroku部署

CircleCI Pipeline result enter image description here
我已經更新了關鍵的Heroku圓詞。

version: 2 
jobs: 
    build: 
    docker: 
     - image: circleci/openjdk:8-jdk 

    working_directory: ~/repo 

    environment: 
     JVM_OPTS: -Xmx3200m 
     TERM: dumb 

    steps: 
     - checkout 

     - restore_cache: 
      keys: 
      - v1-dependencies-{{ checksum "build.gradle" }} 
      - v1-dependencies- 

     - run: gradle dependencies 

     - save_cache: 
      paths: 
      - ~/.m2 
      key: v1-dependencies-{{ checksum "build.gradle" }} 

     # run tests! 
     - run: gradle test 
deployment: 
    staging: 
    branch: master 

    heroku: 
     appname: my-heroku-app 

請問你們能幫助我嗎?部署步驟是否在正確的位置?

回答

0

您正在使用CircleCI 1.0的部署配置,但是您使用的是CircleCI 2.0

從CircleCI 2.0的文檔:

內置集成的Heroku通過CircleCI UI不是 爲CircleCI 2.0實現。但是,可以手動部署到 Heroku。

要與CircleCI 2.0在Heroku上部署,您需要:

  1. 添加環境變量HEROKU_LOGIN,HEROKU_API_KEY,HEROKU_APP_NAME您CircleCI項目設置https://circleci.com/gh/<account>/<project>/edit#env-vars
  2. 創建一個沒有密碼的私人SSH密鑰,並將其添加到您的CircleCI項目設置https://circleci.com/gh/https://circleci.com/gh/<account>/<project>/edit#ssh for hostname git.heroku.com
  3. 使用您的ssh密鑰的指紋在.circleci/config.yml文件中添加步驟
- run: 
     name: Setup Heroku 
     command: | 
     ssh-keyscan -H heroku.com >> ~/.ssh/known_hosts 
     cat > ~/.netrc << EOF 
     machine api.heroku.com 
      login $HEROKU_LOGIN 
      password $HEROKU_API_KEY 
     EOF 
     cat >> ~/.ssh/config << EOF 
     VerifyHostKeyDNS yes 
     StrictHostKeyChecking no 
     EOF 
    - add_ssh_keys: 
     fingerprints: 
     - "<SSH KEY fingerprint>" 
    - deploy: 
     name: "Deploy to Heroku" 
     command: git push --force [email protected]:$HEROKU_APP_NAME.git HEAD:refs/heads/master