Axway-API-Management-Plus / apim-cli

Axway API-Management CLI - Manage your platform from the command line or with your CI/CD pipeline
Apache License 2.0
43 stars 17 forks source link

-returnCodeMapping option does not work on apim-cli org import #496

Open jeroenvandermeulen opened 1 week ago

jeroenvandermeulen commented 1 week ago

APIM-CLI version

1.14.5

API-Management version

7.7.20240530

Bug description

When using the following command:

apim org import -username $APIMGR_USERNAME -password $APIMGR_PASSWORD -apimanagerUrl $APIMGR_URL -s $CI_COMMIT_BRANCH -c ./${PROJECT_DIR}/client-organizations/Example-client-org-name/org-config.yaml -returnCodeMapping 10:0

The command does not exit with 0 when the exit code is 10. This while the option to remap this has been specified. This happens for example when there are no changes found with the following warning:

2024-09-02 08:44:22,197 [APIManagerCLI] INFO : API-Manager CLI: 1.14.5
[20](redacted/-/jobs/81897#L20)24-09-02 08:44:22,200 [APIManagerCLI] INFO : Module: Organization - E X P O R T / U T I L S  (1.14.5)
2024-09-02 08:44:23,507 [APIManagerAdapter] INFO : Successfully connected to API-Manager (7.7.20240530) on: [redacted](redacted)
2024-09-02 08:44:25,964 [OrganizationApp] INFO : You may enable debug to get more details. See: https://github.com/Axway-API-Management-Plus/apim-cli/wiki/9.1.-Enable-Debug
2024-09-02 08:44:25,965 [OrganizationApp] WARN : No changes detected between Desired- and Actual-Org: Example client org name.

We get ERROR: Job failed: command terminated with exit code 10 in our CI and can also validate the same behaviour locally when running echo $?

The -returnCodeMapping option does seem to work when using it in for example apim api import

Steps to reproduce

apim org import -username $APIMGR_USERNAME -password $APIMGR_PASSWORD -apimanagerUrl $APIMGR_URL -s $CI_COMMIT_BRANCH -c ./${PROJECT_DIR}/client-organizations/Example-client-org-name/org-config.yaml -returnCodeMapping 10:0

Relevant log output

2024-09-02 08:44:22,197 [APIManagerCLI] INFO : API-Manager CLI: 1.14.5
[20](redacted/-/jobs/81897#L20)24-09-02 08:44:22,200 [APIManagerCLI] INFO : Module: Organization - E X P O R T / U T I L S  (1.14.5)
2024-09-02 08:44:23,507 [APIManagerAdapter] INFO : Successfully connected to API-Manager (7.7.20240530) on: [redacted](redacted)
2024-09-02 08:44:25,964 [OrganizationApp] INFO : You may enable debug to get more details. See: https://github.com/Axway-API-Management-Plus/apim-cli/wiki/9.1.-Enable-Debug
2024-09-02 08:44:25,965 [OrganizationApp] WARN : No changes detected between Desired- and Actual-Org: Example client org name.
cbrowet-axway commented 1 week ago

I confirm the issue. From a quick look at the code, it seems returnCodeMapping is not implemented for Organizations