【问题标题】:Using Travis to deploy to GitHub and build Tag使用 Travis 部署到 GitHub 并构建 Tag
【发布时间】:2014-07-30 04:27:05
【问题描述】:

我在如何使用 Travis-CI 构建标签并将其部署到 GitHub 上苦苦挣扎了一段时间。 我在this question 上找到了一些相关信息,但不是很清楚,而且对我也不起作用。

我在 gitHub 上创建了一个新的 Release 版本 0.0.0,我正在使用带有 Play Framework 的 Scala,我的 .travis.yml 文件如下:

language: scala
scala:
- 2.10.4
jdk:
- openjdk7

services:
- postgresql

env:
- PLAY_VERSION=2.0.2 DATABASE_USER=postgres DATABASE_PWD='' DATABASE_URL=jdbc:postgresql:testdb  BUILD_KEY=xxxxxxxxxxxxxxxxxxxxxxx

before_script:
- psql -c 'create database testdb;' -U postgres
- wget http://download.playframework.org/releases/play-${PLAY_VERSION}.zip
- unzip -q play-${PLAY_VERSION}.zip
- sudo apt-get install jq
script:
- sbt test
after_success:
  - play-${PLAY_VERSION}/play dist
  - 'ASSETID=$(curl -s -H "Authorization: token ${BUILD_KEY}" "https://api.github.com/repos/Company/spinsurstaging/releases/456729/assets" | jq ".[0].id")'
  - 'curl -XDELETE -s -H "Authorization: token ${BUILD_KEY}" "https://api.github.com/repos/Company/spinsurstaging/releases/assets/$ASSETID"'
  - 'curl -XPOST -s -H "Authorization: token ${BUILD_KEY}" -H "Content-Type: application/zip" --data-binary @./spinsurstaging-0.0-SNAPSHOT.zip "https://uploads.github.com/repos/Company/spinsurstaging/releases/456729/assets?name= spinsurstaging.zip"'

notifications:
email: false

deploy:
  provider: heroku
  api_key: "${HEROKU_KEY}"
  app: spinsurstaging

主要问题是:如何让它发挥作用?有什么问题吗? 还有:我不明白如何将文件spinsurstaging-0.0-SNAPSHOT.zip 发布到github。这个文件来自哪里?有这方面的标准吗? 有没有更好的方法来做到这一点?

提前感谢您帮助我解决这个问题。

【问题讨论】:

    标签: github continuous-integration travis-ci


    【解决方案1】:

    我刚刚想出了如何解决它。 我在代码行上犯了一个错误:

    - 'curl -XPOST -s -H "Authorization: token ${BUILD_KEY}" -H "Content-Type: application/zip" --data-binary @./spinsurstaging-0.0-SNAPSHOT.zip "https://uploads.github.com/repos/Company/spinsurstaging/releases/456729/assets?name= spinsurstaging.zip"'

    正确的代码是:

    - 'curl -XPOST -s -H "Authorization: token ${BUILD_KEY}" -H "Content-Type: application/zip" --data-binary @./spinsurstaging-0.0-SNAPSHOT.zip "https://uploads.github.com/repos/Company/spinsurstaging/releases/456729/assets?name= spinsurstaging .zip"'

    请注意,我更改了快照文件名。此快照是在运行命令play-${PLAY_VERSION}/play dist时创建的

    另一个重要的事情是我必须将PLAY_VERSION 变量更改为2.2.4,因为旧版本没有我用于 sbt 的相同版本的存储库。

    所以我相信我可以回答我所有的问题。希望它可以帮助别人。以下是完整的解决方案:

    language: scala
    scala:
    - 2.10.4
    jdk:
    - openjdk7
    
    services:
    - postgresql
    
    env:
    - PLAY_VERSION=2.2.4 DATABASE_USER=postgres DATABASE_PWD='' DATABASE_URL=jdbc:postgresql:testdb  BUILD_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    
    before_script:
    - psql -c 'create database testdb;' -U postgres
    - wget http://downloads.typesafe.com/play/${PLAY_VERSION}/play-${PLAY_VERSION}.zip
    - unzip -q play-${PLAY_VERSION}.zip
    - sudo apt-get install jq
    script:
    - sbt test
    after_success:
      - play-${PLAY_VERSION}/play dist
      - cd target/universal/
      - 'ASSETID=$(curl -s -H "Authorization: token ${BUILD_KEY}" "https://api.github.com/repos/Company/spinsurstaging/releases/456729/assets" | jq ".[0].id")'
      - 'curl -XDELETE -s -H "Authorization: token ${BUILD_KEY}" "https://api.github.com/repos/Company/spinsurstaging/releases/assets/$ASSETID"'
      - 'curl -XPOST -s -H "Authorization: token ${BUILD_KEY}" -H "Content-Type: application/zip" --data-binary @./spinsurstaging-1.0-SNAPSHOT.zip "https://uploads.github.com/repos/Company/spinsurstaging/releases/456729/assets?name= spinsurstaging'
    
    notifications:
    email: false
    
    deploy:
      provider: heroku
      api_key: "${HEROKU_KEY}"
      app: spinsurstaging
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-10
      • 2014-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-20
      • 2018-01-31
      • 2014-11-13
      相关资源
      最近更新 更多