Override basepath in proxy bundle during deployment

Is there a way to override the basepath in the proxy bundle at the time of deployment of the api proxy using apigeetool or management APIs or any other plugins?

I have the below usecase

The API proxy is built from the source code repo and deployed to Apigee environment through the CI/CD pipeline.

I want to run some integration tests and validate before the API can receive actual traffic.

If there is a way to edit the base path at the time of deployment, i could deploy it as <originalbasepath in code>/inttest

Run the tests, validate the results and then redeploy with the original basepath value so that the actual API traffic can flow through.

I have checked the apigeetool --base-path option, it doesn't override the basepath if its already present in the code.

@Dino-at-Google is there a way to achieve this without actually changing the proxyendpoint xml in the proxy code?

Solved Solved
1 2 534
1 ACCEPTED SOLUTION

is there a way to achieve this without actually changing the proxyendpoint xml in the proxy code?

No.

However, check the "apigee deploy maven plugin". It includes a feature designed specifically for this use case. Actually it's a general templating approach which fills locations in the source files , with data from a config file, according to a "profile" you select at the time you run the deployment. Use the "test" profile, and you can get basepath /test. Use the "prod" profile and you can use a different basepath. But not just basepaths - it can replace any value addressable in the XML config files.

Some resources for you:

If you are not interested in using Maven, you could apply the same config file schema they created using some other tool - maybe something written in a scripting language etc. And follow a similar approach.

OR, if you really just one to change only ONE THING in ONE FILE (the basepath in the proxy endpoint), then you could:

  • check out the code from source repo
  • use a perl edit-in-place one-liner to make the desired change.
  • deploy the proxy
  • run the tests
  • undeploy
  • and then maybe deploy to production.

View solution in original post

2 REPLIES 2

is there a way to achieve this without actually changing the proxyendpoint xml in the proxy code?

No.

However, check the "apigee deploy maven plugin". It includes a feature designed specifically for this use case. Actually it's a general templating approach which fills locations in the source files , with data from a config file, according to a "profile" you select at the time you run the deployment. Use the "test" profile, and you can get basepath /test. Use the "prod" profile and you can use a different basepath. But not just basepaths - it can replace any value addressable in the XML config files.

Some resources for you:

If you are not interested in using Maven, you could apply the same config file schema they created using some other tool - maybe something written in a scripting language etc. And follow a similar approach.

OR, if you really just one to change only ONE THING in ONE FILE (the basepath in the proxy endpoint), then you could:

  • check out the code from source repo
  • use a perl edit-in-place one-liner to make the desired change.
  • deploy the proxy
  • run the tests
  • undeploy
  • and then maybe deploy to production.

@Dino-at-Google Thank you so much for the quick turnaround, I am using the maven plugin in the pipeline. I will try the config option with the profile. Sounds like thats a cleaner way. If that doesn't help, i will try adding a build step to use scripts to replace the basepath in the XML before deployment. The latter one seems to be the easier way though 🙂