【问题标题】:Deploy application using Jenkinsfile and AWS Code deploy使用 Jenkinsfile 和 AWS Code deploy 部署应用程序
【发布时间】:2016-06-14 08:22:04
【问题描述】:

我正在从 Jenkins 1.x 迁移到 Jenkins 2。我想使用 Jenkinsfile 构建和部署应用程序。 我能够构建 gradle 应用程序,但我对使用 Jenkinsfile 通过 AWS Codedeploy 部署应用程序感到困惑。

这是我的詹金斯文件

node {
   // Mark the code checkout 'stage'....
   stage 'Checkout'
   // Get some code from a GitHub repository
      git branch: 'master', 
       credentialsId: 'xxxxxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxx', 
       url: 'https://github.com/somerepo/someapplication.git'

   // Mark the code build 'stage'....
   stage 'Build'
   // Run the gradle build
      sh '/usr/share/gradle/bin/gradle build -x test -q buildZip -Pmule_env=aws-dev -Pmule_config=server'

    stage 'Deploy via Codedeploy'
    //Run using codedeploy agent
}

我搜索了很多教程,但他们使用的是 AWS Code 部署插件。 您能帮我使用 Jenkinsfile 通过 AWS Codedeploy 部署应用程序吗?

谢谢。

【问题讨论】:

    标签: jenkins aws-code-deploy jenkinsfile


    【解决方案1】:

    您也可以使用 AWS CLI 命令进行代码部署。这包括两个步骤。

    第 1 步 - 将部署包推送到 S3 存储桶。请参阅以下命令:

    aws --profile {profile_name} deploy push --application-name {code_deploy_application_name} --s3-location s3://<s3_file_path>.zip
    

    地点:

    1. profile_name = AWS 配置文件的名称(如果使用多个账户)
    2. code_deploy_application_name = AWS 代码部署应用程序的名称。
    3. s3_file_path = 部署包 zip 文件的 S3 文件路径。

    第 2 步 - 启动代码部署 第二个命令用于触发代码部署。请参阅以下命令:

    aws --profile {profile} deploy create-deployment  --application-name {code_deploy_application_name} --deployment-group-name {code_deploy_group_name} --s3-location bucket={s3_bucket_name},bundleType=zip,key={s3_bucket_zip_file_path}

    地点:

    1. profile = 您的 AWS 配置文件的名称(如果使用多个账户)
    2. code_deploy_application_name = 与步骤 1 相同。
    3. code_deploy_group_name = 代码部署组的名称。这与您的代码部署应用程序相关联。
    4. s3_bucket_name = 将存储您的部署工件的 S3 存储桶的名称。 (确保您执行代码部署的角色对 s3 存储桶具有权限。)
    5. s3_bucket_zip_file_path = 与步骤 1 相同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-31
      • 2019-11-14
      • 1970-01-01
      相关资源
      最近更新 更多