Trigger Jenkins build post-deploy

Howdy!

I have a Jenkins job setup for my Selenium regression tests, and I would like to have Octopus trigger this job when the deployment to our QA environment is finished. I’ve been searching through the docs and I can’t seem to find any related information on this. If there is such documentation, could someone refer me to it? If not, could someone please guide me through the actions to take in order to achieve what I want?

PS. The way our infrastructure is built prevents me from running the regression suite with TeamCity before Octopus deploys the app. Hence the need for post-deploy triggers…

Hi @anigma thanks for reaching out.

The easiest way to trigger a job in Jenkins is to use the Jenkins CLI, which is documented at https://jenkins.io/doc/book/managing/cli. By using the CLI from Octopus to trigger a build in Jenkins, you can trigger a build once an Octopus deployment has finished, and then Octopus can wait for the result.

You will most likely want to run the build command, waiting for the build to finish. https://support.cloudbees.com/hc/en-us/articles/228392127-How-to-wait-for-build-to-finish-when-triggering-from-CLI- has some documentation on how to trigger and wait for a build in Jenkins.

So the high level process would be:

  • Octopus completes a deployment
  • Octopus calls the Jenkins CLI to run a build
  • Octopus waits for the build to finish, checks the return code for the status of the job
  • If the Jenkins job was successful, Octopus completes successfully. If the Jenkins job failed, the Octopus deployment will also fail.

Regards
Matt C

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.