{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • General /
avatar image
0
Question by Ashwith G · Jul 11, 2019 at 01:34 PM · 475 Views proxymaven deploy plugincicdrevisionapickliundeploy

CICD Jenkins - Undeploy the revision to earlier deployed revision

Hi @Sai Saran Vaidyanathan, @Siddharth Barahalikar, @Mohsin Khan, @williamssean, @Dino, @Kurt Googler Kanaskie

We are setting up a CICD Jenkins pipeline wherein we are using Apigee Maven Deploy Plugin once the deployment of proxy is done successfully we are planning to execute Apickli Gherkin scripts.

Use_Case: If the Apickli scripts get failed then the deployed revision must be un-deployed. However again it must re-deploy the earlier revision. (HOW CAN WE DO THIS?)

Scenario 1: From the below image_1 initially proxy has been deployed to revision 3 after executing maven deploy plugin a new revision 6 is created and gets deployed, now we are running the Apickli scripts as mentioned in the use_case.

Scenario 2: From the below image_2 initially proxy has been deployed to revision 5 after executing maven deploy plugin a new revision 6 is created and gets deployed, now we are running the Apickli scripts as mentioned in the use_case.

Any help would be appreciated thank you in advance.

Regards,

Ashwith

image-1.png (57.7 kB)
image-2.png (66.7 kB)
Comment
Add comment
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Close

3 Answers

  • Sort: 
avatar image
1

Answer by Sai Saran Vaidyanathan   · Jul 11, 2019 at 04:14 PM

@ash gun

Love the fact that you are using the community very effectively.. Keep it going !!!

The response from @Siddharth Barahalikar is a possible solution however not true in all cases. The script redeploys the previous revision number. For example if Rev 15 failed testing, Rev 14 gets deployed. What if Rev 14 is not stable ? and the most stable Rev is 9 ?

What you could is

1) For every build, pass a roll back revision number as a parameter (for safety) and if the build fails, use the script that is shared, tweak it and just deploy the revision using that parameter

or

2) Pass the stable commit id, branch or tag to the build so that it can pick that code and redeploy as a new revision if the build fails

Comment
Add comment Show 3 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Siddharth Barahalikar   · Jul 11, 2019 at 04:28 PM 0
Link

Yeah, I agree with you. I was just subtracting the newly deployed revision with 1 to deploy to the previous revision. This approach is a big NO when working with live APIs.

It was just for a demo so I left it as it is :D

Thanks for the ideas, I will also update my repo with this :)

avatar image Ashwith G Siddharth Barahalikar · Jul 11, 2019 at 08:33 PM 0
Link

Thanks, @Sai Saran Vaidyanathan & @Siddharth Barahalikar for the response. Looking forward for your updated repo.

avatar image Siddharth Barahalikar Ashwith G   · Jul 15, 2019 at 06:01 AM 0
Link

I have updated my repo.

avatar image
0

Answer by Siddharth Barahalikar   · Jul 11, 2019 at 03:31 PM

Last year I have written a shell scirpt with Management APIs for a use case similar to your Scenario 2.

You can have a look at it in my repo.

https://github.com/sidd-harth/apigee-cicd/blob/master/undeploy.sh

You need to use this in a try..catch block. The script should be placed in catch block, so that it executes only when Apickli test fails.

Comment
Add comment · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Kurt Googler Kanaskie · Jul 11, 2019 at 11:39 PM

I'm with @Sai Saran Vaidyanathan's option 1.

Since my curiosity got the best of me, I implemented using the following sequence of Jenkins plugins and Edge management APIs to get the previously deployed revision and to re-deploy it on failure.

In the Pre Steps section:

Inject environment variables - to set org, env and proxy values.

EdgeOrg=YOUR_ORGNAME
EdgeEnv=YOUR_ENV
EdgeProxy=YOUR_PROXY

Execute shell - to get currently deployed revision (not pretty but it works)

Argh, something's blocking my code block (this is an image)

Inject environment variables - to set the current revision (see screen shot)

Then in the Post Steps section:

Conditional Step (single) - Run? Current build status with "Failed" for both worst and best status.

Execute shell - to get newly deployed revision and if they're different re-deploy the $PreviousRev

Argh, something's blocking my code block (this is an image)

See attached screen shots for additional clarity.


screen-shot-2019-07-11-at-72923-pm.png (58.7 kB)
screen-shot-2019-07-11-at-73316-pm.png (111.9 kB)
screen-shot-2019-07-11-at-75543-pm.png (53.0 kB)
screen-shot-2019-07-11-at-75643-pm.png (185.0 kB)
Comment
Add comment · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

60 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Automate bundle creation using openAPISpec + add necessary policies + push it to edge - cicd using Azure Devops 1 Answer

Apigeetool + CI/CD: deploy proxy multiple times results in n+1 revision in same organisation 3 Answers

API Proxy Revision Issue 1 Answer

How to determine a particular proxy change in a Git repo with N number of proxies 1 Answer

Separating proxy and config deployment using maven plugin 1 Answer

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges