git - Jenkins 构建 CloudFormation Stack,然后通过 CodeDeploy 插件部署代码

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

我将 Jenkins 与 CloudFormation 和 CodeDeploy 插件结合使用。

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

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

问题:

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

干杯

最佳答案

您可以将这两者放在一项工作中。这里它处于两个阶段的声明式管道中:

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'
      }
    }
  }
}

关于git - Jenkins 构建 CloudFormation Stack,然后通过 CodeDeploy 插件部署代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44479583/

相关文章:

推送后 Gitlab 不显示提交

python - 有没有办法让 Python 脚本到 "recognize"它运行的是哪个 EC2 实例?

java - 亚马逊 Elastic Beanstalk 广播

.net - 当我尝试使用 NUGet 构建 .Net 项目时遇到问题

git - 使用 Jenkinsfile 一个分支中的多个管道

Git: merge 多个存储库

git - "@@"之间的信息在git diff中意味着什么

eclipse - 是否可以在 EGit 的一个工作流程中进行 pull 、提交和推送?

amazon-web-services - 私有(private)子网中的 EC2 实例无法访问亚马逊存储库

java - Jenkins 作业和 GIT/maven 结构