Apigee maven plugin - config.json file error

Hello All,

I have created a config.json file with below data. Placed this file under main folder where apiproxy is there.

The intension of using this file is to insert the value or replace the value of a parameter in a policy.

 

However, deployment is failing. Is this the correct way to use it ?

I also have another .json files for each environment which has details about target servers, products...etc. Do i need to mention below in same edge.json files or keep it separate.

 

Config.json

 

{
"configurations": [
{
"name": "test",
"policies": [
{
"name": "FC-ELK-Logger",
"tokens": [
{
"xpath": "/FlowCallout/Properties/Parameters",
"value": "stgtest"
}
]
}
]
}
]
}

 

@ssvaidyanathan : Please support here.

Regards,

Murthy.

0 8 409
8 REPLIES 8

@Murthy - will need more info

What mvn command are you executing? What is the error you are seeing? What does your FlowCallout policy look like before making the change?

hi @ssvaidyanathan please find the details

 

 

-Pmoj_real_stage -Dapigee.config.options=create -s C:\settings.xml -Dusername=$(user_local) -Dpassword=$(user_pass) -Doptions=validate -Dprofile=moj-internal-clients -Dapigee.config.file=$(System.DefaultWorkingDirectory)/$(Edge_BranchName)/stage-edge.json

 

 

Before:

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FlowCallout async="false" continueOnError="false" enabled="true" name="FC-ELK-Logger">
<DisplayName>FC-ELK-Logger</DisplayName>
<FaultRules/>
<Properties/>
<SharedFlowBundle>ELK-Logger</SharedFlowBundle>
</FlowCallout>

 

 

As a part of new pipeline

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FlowCallout async="false" continueOnError="false" enabled="true" name="FC-ELK-Logger">
<DisplayName>FC-ELK-Logger</DisplayName>
<FaultRules/>
<Properties>
<Parameters>stg</Parameters>
</Properties>
<SharedFlowBundle>ELK-Logger</SharedFlowBundle>
</FlowCallout>

 

 

 

Requirement: I would like to insert the orgname to which the deployment is happening during the deployment in policy FC-ELK-Logger which is the insertion of shared flow ELK-Logger

The pipeline takes the orgname  from "-Dorg orgname". Right now, i'm testing to replace the parameter value "stg" under policy FC-ELK-Logger of sharedflow FlowCallout. Late, it needs to be replaced with org name.

 

Could you please support here.

 

Regards,

Murthy

@Murthy - First of all the syntax you have is incorrect. Please see our documentation for the correct syntax. It should not be Properties --> Parameters, it should be like the one below:

 

 

<Parameters>
  <Parameter name="input">Gladys Kravitz</Parameter>
  <Parameter name="outputVariable">string.handler.output</Parameter>
</Parameters>

 

 

For your example, if you want to pass the org name as the parameter, you dont really need to do this as a build time change through the plugin. The Parameter accepts variables too. You can just update your FlowCallout policy to something like this

 

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FlowCallout async="false" continueOnError="false" enabled="true" name="FC-ELK-Logger">
  <DisplayName>FC-ELK-Logger</DisplayName>
  <FaultRules/>
  <Properties>
  <Parameters>
    <Parameter name="org">{organization.name}</Parameter>
  </Parameters>
  </Properties>
  <SharedFlowBundle>ELK-Logger</SharedFlowBundle>
</FlowCallout>

 

 

The policy will pick the value automatically at runtime. 

On the other hand, if you plan to only send org name, then its a flow variable already available in the sharedflow. You really dont need to send it specifically from the FlowCallout to the sharedFlow. It should already have it and you can just directly use "organization.name" variable and it will automatically populate it with the org name.

@Murthy - pls mark this as resolved if the provided answer resolved your issue

Hello @ssvaidyanathan the requirement here is that. We have multiple ORG's in Development and single ORG in Stage and Production environments.

We also have 3 stages in pipeline, each for dev, stage and Prod.

Developers deploy in their own ORG in dev env but in stage and prod env, its single org. 

We need to track the ORG of dev env and place that ORG name in Stage and Prod FC-ELK-LOGGER.  I'm unable to bring that env since i'm not using the 

-Dorg orgname variable also.

 

Could you please support here.

 

Regards,

Murthy

Then why don't you use it? My point is - this need not be a build time config, its available for you at runtime itself. So just use that. You just need to update your policy to use the organization.name variable in your policy. Thats it. You dont have to make any other change.

@ssvaidyanathan Sorry, may be i didn't convey my point correctly.

If we mention "organization.name" variable in policy, it will take the name as "stg" and "prod" in stage and production setups respectively since we have only one org in each in stage and production environment. 

May be this scenarios helps.

 

Developer-1 deployed the proxy in dev environment of org devorg1 and used the variable organization.name in policy. The the policy gets updated with value devorg1

He used the pipeline which has three stages of deploy in CD pipeline. When he deploys the same proxy in stage and prod the policy gets updated with "stg" and "prod" as it takes the local org of that stage and production environment.

 

 

Developer-2 deployed the proxy2 in dev2 environment of org devorg2 and used the variable organization.name in policy. The the policy gets updated with value devorg2

He used the pipeline which has three stages of deploy in CD pipeline. When he deploys the same proxy2 in stage and prod the policy gets updated with "stg" and "prod" as it takes the local org of that stage and production environment.

 

My requirement in both cases is to update the policy with name devorg1 in case-1 and devorg2 in case-2 when he deploys in stage and production environments.

The policy in stage and production setup should take the org name of dev environment not the stage and production environments.

 

Hope i'm clear. I believe organization.name is the flow variable but not pipeline variable.

 

Regards,

Murthy

 

Still not very clear. I just feel its complicated

Here are my options I can think of

1) Use Maven replacer plugin and replace the values on the file during build time. You can check this. It basically replaces the token with the value you want. See my sample, you will see that I am replacing certain tokens with some values across files.

2) Use the config.json that the Maven deploy plugin supports. But you cannot use update the entire policy, you can just update the value 

For example:

Your policy will be

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FlowCallout async="false" continueOnError="false" enabled="true" name="FC-ELK-Logger">
<DisplayName>FC-ELK-Logger</DisplayName>
<FaultRules/>
<Properties>
<Parameters>
<Parameter name="org">something</Parameter>
</Parameters>
</Properties>
<SharedFlowBundle>ELK-Logger</SharedFlowBundle>
</FlowCallout>

And then you can use the config.json to pass the token to replace "something" with the actual value