-1

Jenkins から Cloud に war をデプロイしたい。

ローカルの Jenkins から AWS Bean Stalk に war ファイルをデプロイする方法を教えてください。

Jenkins ポストプロセス プラグインを使用してアーティファクトを S3 にコピーしようとしましたが、次のエラーが発生します。

ERROR: Failed to upload files java.io.IOException: put Destination [bucketName=https:, objectName=/s3-eu-west-1.amazonaws.com/bucketname/test.war]:
com.amazonaws.AmazonClientException: Unable to execute HTTP request: Connect to s3.amazonaws.com/s3.amazonaws.com/ timed out at hudson.plugins.s3.S3Profile.upload(S3Profile.java:85) at hudson.plugins.s3.S3BucketPublisher.perform(S3BucketPublisher.java:143)
4

1 に答える 1

1

これに関していくつかの作業が行われました。

http://purelyinstinctual.com/2013/03/18/automated-deployment-to-amazon-elastic-beanstalk-using-jenkins-on-ec2-part-2-guide/

基本的に、これはビルド後のタスクを追加して、標準のコマンド ライン デプロイ スクリプトを実行するだけです。

参照ページから、Jenkins にポストビルド タスク プラグインがあり、AWS コマンド ライン ツールがインストールされていると仮定します。

ステップ1

Jenkins ジョブ設定画面で、「ビルド後のアクション」を追加し、プラグイン「アーティファクトを S3 バケットに公開」を選択し、ソースを指定します (この例では Maven を使用しているため、ソースは target/.war で、宛先はあなたのS3 バケット名)

ステップ2

次に、「ビルド後のタスク」(持っていない場合、これは Maven リポジトリのプラグインです) を上記の同じセクション (「ビルド後のアクション」) に追加し、「アーティファクトを S3 に公開する」の下にドラッグします。バケツ"。スクリプトに進む前に、war ファイルが S3 にアップロードされていることを確認することが重要です。

ビルド後のタスク部分で、[以前のすべてのステップが成功した場合にのみスクリプトを実行する] チェックボックスをオンにしてください。</p>

スクリプト テキスト領域に、展開を自動化するスクリプトのパスを入力します (以下の手順 3 で説明)。私たちの場合、次のようなものを置きます。

<path_to_script_file>/deploy.sh "$VERSION_NUMBER" "$VERSION_DESCRIPTION"

$VERSION_NUMBER と $VERSION_DESCRIPTION は Jenkins のビルド パラメータであり、デプロイがトリガーされるときに指定する必要があります。両方の変数が AEB 展開に使用されます

ステップ3

スクリプト

#!/bin/sh
export AWS_CREDENTIAL_FILE=<path_to_your aws.key file>
export PATH=$PATH:<path to bin file inside the "api" folder inside the AEB Command line tool (A)>
export PATH=$PATH:<path to root folder of s3cmd (B)>

//get the current time and append to the name of .war file that's being deployed.
//This will create a unique identifier for each .war file and allow us to rollback easily.
current_time=$(date +"%Y%m%d%H%M%S")
original_file="app.war"
new_file="app_$current_time.war"

//Rename the deployed war file with the new name.
s3cmd mv "s3://<your S3 bucket>/$original_file" "s3://<your S3 bucket>/$new_file"

//Create application version in AEB and link it with the renamed WAR file
elastic-beanstalk-create-application-version -a "Hoiio App" -l "$1" -d "$2" -s "<your S3 bucket>/$new_file"
于 2013-07-18T15:50:13.347 に答える