1

I have a Jenkinsfile having a path in this order (assuming Green envs are binded to production only):

Build-->Deploy-to-QA-->Deploy-To-Preprod-->Deploy-To-BLUE-Production-->Bind to Blue envs to Load Balancer--> Unbind Green Env-->Deploy to Green--> Bind Green--> Unbind Blue

This order seems to be good if we are being too optimistic,because in some cases, there might be a problem with green env, and admin user can bind the blue envs manually, or both can be binded together to the production.

Therefore, I have written a script which makes an API call to the LB and gets the binded service group.

But I could not figure out how to redirect the pipeline by getting the result of api.

If endpoint returns blue is binded, it should start deploying from green, if endpoint returns green is binded info, it should start deploying from blue env in my case.

But as far as I see, I cannot wrap the stages within a function in Jenkinsfile.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Are you using declarative pipelines? It sounds like you need to use `script` in a stage to make that logic decision. – mkobit Dec 14 '17 at 18:06
  • you cannot wrap stages in a function. However, you can write a function and use it as a shared library. Take a look at https://github.com/SAP/cloud-s4-sdk-pipeline, here pipeline makes use of the shared library. You can configure shared libraries as explained here https://jenkins.io/doc/book/pipeline/shared-libraries/. – Ram Dec 19 '17 at 13:30
  • thanks a lot @RamKamath,the pipeline you shared helped me a lot , shared libraries seem to be a strong feature of jenkins – Gökçe Sürenkök Dec 21 '17 at 11:34

0 Answers0