Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Jenkins Pipeline Utility Steps zip zipFile is not creating proper apiproxy zip file.

Hi,

We are using Jenkins pipeline to make Apigee API calls for creating the apipoxy. Here is code for jenkins pipeline:

            steps {
                script {
                        // Inside apiproxy we have all the files and folders.
                         def directoryPath = "/apiproxy";          
                        zip zipFile: 'apiproxy.zip',archive: false, dir: directoryPath
 
                      sh '''
                       curl -X POST -u <credential> -H "content-type: multipart/form-data" -F "file=@apiproxy.zip"                           "http://<domain>/v1/organizations/<org>/apis?action=import&name=myproxy"
                       '''
                    }
            }
This call  zip zipFile: 'apiproxy.zip',archive: false, dir: directoryPath creates apiproxy.zip file on workspace. We are using aws linux slave for jobs. Here is error for pipleline output.
 
> POST /v1/organizations/<org>/apis?action=import&name=myproxy HTTP/1.1
> User-Agent: curl/7.29.0
> Accept: */*
> Content-Length: 1359
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=----------------------------<number>
>
< HTTP/1.1 100 Continue
} [data not shown]
< HTTP/1.1 400 Bad Request
< X-Apigee.fault-code: messaging.config.beans.InvalidBundle
< Content-Type: application/json
< X-Apigee.backends: 
< Content-Length: 122
* HTTP error before end of send, stop sending
 
We can download the apiproxy.zip on windows but can't make curl command also from cmd prompt. It is sating  messaging.config.beans.InvalidBundle error. It shows zip has some issues.
 
We tried to create zip file using linux tar command but it is also failing in curl command using jenkins pipeline.
 
Please suggest.
 
Thanks

 

Solved Solved
0 13 5,667
2 ACCEPTED SOLUTIONS

Invalid bundle can mean ... lots of things. One possibility is that your bundle is referencing a policy that is not included in the bundle. Or maybe your bundle is missing a target endpoint. Another possibility is that one of your XML files is malformed.  

May I suggest that you run apigeelint on the bundle before uploading the bundle to the management server?   Apigeelint gives you clear error messages and warnings about such things, as well as many other style or usage problems. 

If you cannot do that, then, I suggest that you examine the full error message returned from the management server with the 400 status code.  Usually there is an error message that specifies exactly what the problem is.  If you cannot do that, ,then.... perhaps consult the system.log for the management server. I am guessing that you are using OPDK, from the http:// scheme on the management server URL. If you are using OPDK then you have access to the system.log of the management server and it may have a message there that describes the problem with the invalid bundle. 


@deepak-1 wrote:

It is sating  messaging.config.beans.InvalidBundle error. It shows zip has some issues.


 

Can you be SPECIFIC about "some issues"?   When you download the apiproxy.zip and try to upload it (==import it into Apigee, I guess) via a curl command, WHAT IS THE COMPLETE ERROR MESSAGE? If you run curl with the -i option, you will see the response payload with the error message. 

Or you can run apigeelint on that zip file. 

good luck

View solution in original post

GREAT. I'm glad to hear you resolved the problem. The correct structure for an API proxy zip bundle is, the folder apiproxy must be the containing directory for all assets. An example is here:

  Length      Date    Time    Name
---------  ---------- -----   ----
        0  10-17-2023 11:30   apiproxy/
      338  10-12-2023 13:52   apiproxy/name-of-api-proxy-here.xml
        0  10-17-2023 11:33   apiproxy/targets/
     1530  10-17-2023 11:33   apiproxy/targets/target-endpoint-here.xml
        0  10-17-2023 11:32   apiproxy/policies/
      373  10-09-2023 12:58   apiproxy/policies/policies-here.xml
      396  10-12-2023 15:00   apiproxy/policies/...
        0  10-17-2023 11:33   apiproxy/proxies/
     2759  10-17-2023 11:33   apiproxy/proxies/proxy-endpoint-here.xml

The documentation for this is here.

View solution in original post

13 REPLIES 13
Top Solution Authors