3

我想從travis ci自動部署一個jar到aws彈性beanstalk。在我看來,像travis正在上傳一個包含源代碼內容的zip文件,而不是上傳構建的jar。根據文檔,我不清楚如何指示travis上傳jar而不是原始源代碼。特拉維斯部署一個zip而不是一個罐子

.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 

這裏是從豆莖的輸出。它詳細介紹了試圖執行的文件上傳特拉維斯時遇到的問題:

青苗錯誤日誌

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。

+0

Travis中的彈性豆杆支撐是否實驗?到目前爲止,這就是我所看到的。如果你有文檔,或許我們可以進一步提供幫助。不過,我想我會避免使用實驗性功能。您可以使用Travis S3功能將文件zip或jar推送到S3。然後將AWS CodePipeline設置爲部署到ElasticBeanstalk。這是所有原生功能和易於設置。 –

+0

雖然這很公平,但對於AWS CodeDeploy存在同樣的問題(我假設您的意思是CodeDeploy而不是CodePipeline)。 CodeDeploy配置似乎希望你指定包(jar的位置)。我不知道Travis在哪裏存儲構建的jar,並且文檔沒有給我一個方法來弄清楚,我可以看到。 – melchoir55

回答

2

最終,這裏有兩個問題。第一個是Gradle實際上並沒有輸出一個罐子。我修改了build.gradle來做到這一點。其次,看起來,elasticbeanstalk支持不是用java(或任何編譯語言)創建的。也就是說,它仍然有可能得到它的工作。關鍵字段是zip_file。這個字段最好命名爲archive甚至file,因爲你可以通過罐子,戰爭,拉鍊或任何你喜歡的東西。下面.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這個內置相對於工作目錄罐子輸出。