gpt4 book ai didi

java - Travis 部署一个 zip 而不是一个 jar

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:13:25 26 4
gpt4 key购买 nike

我正在尝试将 jar 从 travis ci 自动部署到 aws elastic beanstalk。在我看来,travis 正在上传一个包含源代码内容的 zip 文件,而不是上传构建的 jar。根据文档,我不清楚如何指示 travis 上传 jar 而不是原始源代码。

.travis.yml

language: java
jdk:
- oraclejdk8
deploy:
provider: elasticbeanstalk
skip_cleanup: true
app: OptionsTradeAnalysis
env: ota-api-env
file: "ota.jar"
bucket_name: elasticbeanstalk-us-west-2-302145366589
region: us-west-2
access_key_id:
secure: key
secret_access_key:
secure: key
on:
repo: melchoir55/OptionsAnalysis
branch: master

这是 beantalk 的输出。它详细说明了它在尝试执行 travis 上传的文件时遇到的问题:

Beanstalk 错误日志

Application update failed at 2016-11-10T03:52:56Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/01_configure_application.sh failed.

Executing: /usr/bin/unzip -o -d /var/app/staging /opt/elasticbeanstalk/deploy/appsource/source_bundle
Archive: /opt/elasticbeanstalk/deploy/appsource/source_bundle
inflating: /var/app/staging/.gitignore
inflating: /var/app/staging/.gradle/2.13/taskArtifacts/cache.properties
inflating: /var/app/staging/.gradle/2.13/taskArtifacts/cache.properties.lock
inflating: /var/app/staging/.gradle/2.13/taskArtifacts/fileHashes.bin
inflating: /var/app/staging/.gradle/2.13/taskArtifacts/fileSnapshots.bin
inflating: /var/app/staging/.gradle/2.13/taskArtifacts/taskArtifacts.bin
inflating: /var/app/staging/.travis.yml
inflating: /var/app/staging/LICENSE
inflating: /var/app/staging/README.md
inflating: /var/app/staging/build.gradle
inflating: /var/app/staging/gradle/wrapper/gradle-wrapper.jar
inflating: /var/app/staging/gradle/wrapper/gradle-wrapper.properties
inflating: /var/app/staging/gradlew
inflating: /var/app/staging/gradlew.bat
inflating: /var/app/staging/settings.gradle
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/Application.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/api/ApiConstants.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/api/resourceController/OptionTransactionController.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/api/resourceController/VersionController.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/database/dao/OptionDao.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/database/dao/OptionTransactionDao.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/database/dao/PriceDao.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/database/dao/StockDao.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/model/Analysis/PercentageGain.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/model/Analysis/TimeRange.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/model/ModelUtils.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/model/Option.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/model/OptionPrice.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/model/OptionTransaction.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/model/Price.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/model/Stock.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/model/StockPrice.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/model/TransactionAnalysis.java
inflating: /var/app/staging/src/main/java/com/zowda/optionsAnalysis/model/User.java
inflating: /var/app/staging/src/main/resources/application.properties
inflating: /var/app/staging/src/test/java/com/zowda/optionsAnalysis/test/api/ApiTestUtils.java
inflating: /var/app/staging/src/test/java/com/zowda/optionsAnalysis/test/api/resourceController/OptionTransactionControllerTest.java
inflating: /var/app/staging/src/test/java/com/zowda/optionsAnalysis/test/api/resourceController/VersionControllerTest.java
inflating: /var/app/staging/src/test/java/com/zowda/optionsAnalysis/test/database/DatabaseBasicsTest.java
inflating: /var/app/staging/src/test/java/com/zowda/optionsAnalysis/test/model/analysis/PercentageGainTest.java
inflating: /var/app/staging/src/test/java/com/zowda/optionsAnalysis/test/model/analysis/TimeRangeTest.java
inflating: /var/app/staging/src/test/java/com/zowda/optionsAnalysis/test/model/testFactories/OptionTransactionTestFactory.java
inflating: /var/app/staging/src/test/java/com/zowda/optionsAnalysis/test/model/testFactories/PercentageGainTestFactory.java
inflating: /var/app/staging/src/test/java/com/zowda/optionsAnalysis/test/model/testFactories/TimeRangeTestFactory.java
inflating: /var/app/staging/src/test/resources/application.properties
Unable to launch application as the source bundle does not contain either a file named application.jar or a Procfile.
Unable to launch application as the source bundle does not contain either a file named application.jar or a Procfile.
Incorrect application version "travis-d1bff950714be0a82e46a827346ada041aa71aad-1478749923" (deployment 6). Expected version "Sample Application" (deployment 1).

请注意,我也尝试过在没有 file 参数的情况下运行它,因为我不清楚该参数的作用。我得到了相同的结果。正如您在这里看到的,我假设该参数用于命名 travis 正在部署的文件,但根据我得到的行为,我认为我可能是错的。我突然想到,开发人员可以指定要上传的文件的位置,但我不知道 travis 将构建的 jar 放在哪里。

最佳答案

最终,这里有两个问题。首先是 gradle 实际上并没有输出 jar。我修改了 build.gradle 来做到这一点。其次,似乎 elasticbeanstalk 支持并不是在考虑 java(或任何编译语言)的情况下创建的。也就是说,仍然有可能让它发挥作用。关键字段是 zip_file。该字段最好命名为 archive 甚至 file,因为您可以传递 jars、wars、zip 或任何您喜欢的内容。下面的 .travis.yml 对我有用:

.travis.yml

language: java
jdk:
- oraclejdk8
deploy:
provider: elasticbeanstalk
skip_cleanup: true
app: OptionsTradeAnalysis
env: ota-api-env
zip_file: 'build/libs/OptionsAnalysis-1.0.jar'
bucket_name: elasticbeanstalk-us-west-2-302145366589
region: us-west-2
access_key_id:
secure: key
secret_access_key:
secure: key
on:
repo: melchoir55/OptionsAnalysis
branch: master

注意zip_file中指定的路径是gradle输出构建的jar相对于工作目录的路径。

关于java - Travis 部署一个 zip 而不是一个 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40519788/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com