【问题标题】:Jenkins to build CloudFormation Stack then deploy code via CodeDeploy pluginJenkins 构建 CloudFormation Stack,然后通过 CodeDeploy 插件部署代码
【发布时间】:2017-11-12 18:11:21
【问题描述】:

我将 Jenkins 与 CloudFormation 和 CodeDeploy 插件一起使用。

当我的 git repo 有新的提交时,我可以使用 jenkins 构建 CloudFormation 堆栈。

我也可以通过 CodeDeploy 插件将代码部署到我在 Auto Scaling 组中的 EC2 实例。

问题:

如何使整个过程自动化,以便在我创建 CloudFormation Stack 的 Jenkins 作业完成后,接下来可以触发 CodeDeploy 作业以完成代码部署过程。

干杯

【问题讨论】:

    标签: git amazon-web-services jenkins amazon-cloudformation aws-code-deploy


    【解决方案1】:

    你可以把这两者都放在一份工作中。这里是一个声明性管道,分两个阶段:

    pipeline {
      agent { label 'docker' }
      stages {
        stage('cloudformation') {
          steps {
            sh './do_cloudformation.sh'
          }
        }
        stage('codedeploy') {
          steps {
            sh './do_codedeploy.sh'
          }
        }
      }
    }
    

    如果您希望能够独立触发它们,可以将它们保留在两个作业中,但让 cloudformation 作业触发 codedeploy 作业,使用 build step,如下所示:

    pipeline {
      agent { label 'docker' }
      stages {
        stage('cloudformation') {
          steps {
            sh './do_cloudformation.sh'
          }
        }
        stage('codedeploy') {
          steps {
            build 'name-of-codedeploy-job'
          }
        }
      }
    }
    

    【讨论】:

    • 感谢朋友的回复。我最终使用了对我有用的“构建触发器”->“构建其他项目后构建”选项。
    【解决方案2】:

    通过选择“构建触发器”和“构建其他项目后构建”选项解决了该问题

    【讨论】:

      猜你喜欢
      • 2018-04-27
      • 2019-09-21
      • 2020-05-19
      • 2016-02-12
      • 1970-01-01
      • 1970-01-01
      • 2020-02-26
      • 1970-01-01
      • 2016-09-13
      相关资源
      最近更新 更多