0

I'm using Jenkins with CloudFormation and CodeDeploy plugin.

I am able to use jenkins to build CloudFormation stack when there is new commit to my git repo.

I'm able to deploy code to my EC2 instances in auto scaling group via CodeDeploy plugin as well.

Question:

How can I automate the entire process so that when my Jenkins job to create CloudFormation Stack is completed the CodeDeploy job can be triggered next to complete the code deployment process.

Cheers

AD7
  • 105
  • 1
  • 11

2 Answers2

1

you could put both of these in one job. here it is in a declarative pipeline in two stages:

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

if you want to be able to trigger them independently, you could keep them in two jobs, but have the cloudformation job trigger the codedeploy job, by using the build step, like this:

pipeline {
  agent { label 'docker' }
  stages {
    stage('cloudformation') {
      steps {
        sh './do_cloudformation.sh'
      }
    }
    stage('codedeploy') {
      steps {
        build 'name-of-codedeploy-job'
      }
    }
  }
}
burnettk
  • 13,557
  • 4
  • 51
  • 52
  • Thanks for the reply mate. I end up using 'Build trigger' -> 'Build after other projects are built' option which worked for me. – AD7 Jun 15 '17 at 04:34
0

Resolved the issue by selecting 'Build Triggers' with 'Build after other projects are built' option

AD7
  • 105
  • 1
  • 11