It is now possible to manage hybrid app versions using a Curl command.
For HCPms
Prerequisite:
- Valid SAP HCP trial account
- Subscription to to HANA Cloud Platform Mobile Services
- Make sure you have created a hybrid project with kapsel appUpdate plugin (reference)
- Create a package for the same app by running kapsel package command
Open HCPms cockpit (
https://hcpmsadmin-pxxxxtrial.dispatcher.hanatrial.ondemand.com/) , create an application.
Deploy a Hybrid App
There are two ways of doing it. If you are an Administrator or have access to HCPms cockpit, you can directly navigate to APP SPECIFIC SETTINGS of this particular application id, click on 'upload kapsel' and browse to zip file (as mentioned in prerequisite)
If you dont have access to cockpit or you have only READ access (Helpdesk role) in case of on-premise SMP, then there is another way of doing it.
1. Make a GET request to retrieve CSRF Token value and cookies
curl --header "X-CSRF-TOKEN:fetch" --user p1176845 -X GET -i https://hcpms-p1176845trial.hanatrial.ondemand.com/Admin/kapsel/jaxrs/KapselApp/com.mycompany.appupd...
Enter HCPms password
(As you can see that in the last there is a blank [] because there is no kapsel app available for this app id at the moment)
copy CSRF-Token value and cookies and pass it to a new command like below:
curl --header "X-CSRF-Token:731E5DF6FAA320851F8DDF6E4FA73C2E" --header "Cookie:X-SMP-SESSID=8B4FEC8BFE1036712971BD3F521BE99390E98A60335BC3B049D9B9AA4D810CC1; Path=/; Secure; HttpOnly;JTENANTSESSIONID_p1176845trial=rllpIfiEF0I%2FlfpU90YUdmDo0STWbx9gPB4SjKCWT4w%3D; Domain=.hanatrial.ondemand.com; Path=/; Secure; HttpOnly" -v -k --user p1176845 --form "file=@F:\Kapsel_Projects\AppUpdateDemo\packagedKapselApp.zip" -i https://hcpms-p1176845trial.hanatrial.ondemand.com:443/Admin/kapsel/jaxrs/KapselApp/com.mycompany.ap...
Now i am going to upload zip file to HCPms
Retrieve a Hybrid App Details
You can retrieve details about an hybrid app (new, current, stage version) by just calling a GET request
curl --user p1176845 -X GET -i https://hcpms-p1176845trial.hanatrial.ondemand.com/Admin/kapsel/jaxrs/KapselApp/com.mycompany.appupd...
Promote a Hybrid App
Once an hybrid app is available, you can promote it to make it the staged version or current version.
Stage version: Mainly for test users for testing before revision is fully deployed to end users
Current Version: Main application revision end users are using
case 1:
Move app from NEW VERSION to STAGE version
You can find revision version, platform information in GET command (as you can see in above CMD screenshot)
curl --header "X-CSRF-Token:731E5DF6FAA320851F8DDF6E4FA73C2E" --header "Cookie:X-SMP-SESSID=8B4FEC8BFE1036712971BD3F521BE99390E98A60335BC3B049D9B9AA4D810CC1; Path=/; Secure; HttpOnly;JTENANTSESSIONID_p1176845trial=rllpIfiEF0I%2FlfpU90YUdmDo0STWbx9gPB4SjKCWT4w%3D; Domain=.hanatrial.ondemand.com; Path=/; Secure; HttpOnly" -v -k --user p1176845 -i https://hcpms-p1176845trial.hanatrial.ondemand.com:443/Admin/kapsel/jaxrs/KapselApp/com.mycompany.ap... -X PUT -d "[{\"platform\": \"android\",\"revisions\":[-1]}]" -H "Content-Type: application/json"
Now, app has moved to STAGED version, testers can use this application revision for testing.
case 2: Once testing is done, this app can be pushed to CURRENT version, available for end users.
curl --header "X-CSRF-Token:731E5DF6FAA320851F8DDF6E4FA73C2E" --header "Cookie:X-SMP-SESSID=8B4FEC8BFE1036712971BD3F521BE99390E98A60335BC3B049D9B9AA4D810CC1; Path=/; Secure; HttpOnly;JTENANTSESSIONID_p1176845trial=rllpIfiEF0I%2FlfpU90YUdmDo0STWbx9gPB4SjKCWT4w%3D; Domain=.hanatrial.ondemand.com; Path=/; Secure; HttpOnly" -v -k --user p1176845 -i https://hcpms-p1176845trial.hanatrial.ondemand.com:443/Admin/kapsel/jaxrs/KapselApp/com.mycompany.ap... -X PUT -d "[{\"platform\": \"android\",\"revisions\":[1]}]" -H "Content-Type: application/json"
case 3: You can directly promote an app from NEW VERSION to CURRENT VERSION also.
https://hcpms-p1176845trial.hanatrial.ondemand.com:443/Admin/kapsel/jaxrs/KapselApp/com.mycompany.ap...
case 4 : from STAGED VERSION to NEW VERSION
https://hcpms-p1176845trial.hanatrial.ondemand.com:443/Admin/kapsel/jaxrs/KapselApp/com.mycompany.ap...
Deleting an Hybrid App
If you have set of revisions of Hybrid App in
NEW VERSION section, you can remove it by using -X DELETE
Case 1: To delete all hybrid apps,
URL:
https://hcpms-p1176845trial.hanatrial.ondemand.com:443/Admin/kapsel/jaxrs/KapselApp/com.mycompany.ap...
curl --header "X-CSRF-Token:731E5DF6FAA320851F8DDF6E4FA73C2E" --header "Cookie:X-SMP-SESSID=8B4FEC8BFE1036712971BD3F521BE99390E98A60335BC3B049D9B9AA4D810CC1; Path=/; Secure; HttpOnly;JTENANTSESSIONID_p1176845trial=rllpIfiEF0I%2FlfpU90YUdmDo0STWbx9gPB4SjKCWT4w%3D; Domain=.hanatrial.ondemand.com; Path=/; Secure; HttpOnly" -v -k --user p1176845 -i https://hcpms-p1176845trial.hanatrial.ondemand.com:443/Admin/kapsel/jaxrs/KapselApp/com.mycompany.ap... -X DELETE
Case 2: To delete a hybrid app from a particular platform
URL
: https://hcpms-p1176845trial.hanatrial.ondemand.com:443/Admin/kapsel/jaxrs/KapselApp/com.mycompany.ap...
Case 3: To delete a particular revision for a specified platform
URL:
URL: https://hcpms-p1176845trial.hanatrial.ondemand.com:443/Admin/kapsel/jaxrs/KapselApp/com.mycompany.ap... and add
d "[{\"platform\": \"android\",\"revisions\":[-1]}]" -H "Content-Type: application/json
like this:
curl --header "X-CSRF-Token:C2C5E1135618958352837DBA1183F02D" --header "Cookie:X-SMP-SESSID=BD8B6793BF950AAC790BD0B48CEFFD205A2E33A5D70D14908B3B4D76C6396C99; Path=/; Secure; HttpOnly;X-SMP-SESSIDSSO=15B55914E49EAE106F0E2D133D7C1CD0; Path=/; Secure; HttpOnly" -v -k --user JK -i https://JK:8083/Admin/kapsel/jaxrs/KapselApp/com.mycompany.appupdate/android -X DELETE d "[{\"platform\": \"android\",\"revisions\":[-1]}]" -H "Content-Type: application/json
Case 4: To delete a set of REVISION for a specified platform
[{"platform": "android","revisions":[1,2,3]}
For SMP on-premise
prerequisite: SMP 3.0 SP09 runtime
Fetch CSRF-Token: curl --header "X-CSRF-TOKEN:fetch" --user JK -X GET -i https://smpserverip:8083/Admin/kapsel/jaxrs/KapselApp/com.mycompany.appupdate -k
Deploy: curl --header "X-CSRF-Token:C2C5E1135618958352837DBA1183F02D" --header "Cookie:X-SMP-SESSID=BD8B6793BF950AAC790BD0B48CEFFD205A2E33A5D70D14908B3B4D76C6396C99; Path=/; Secure; HttpOnly;X-SMP-SESSIDSSO=15B55914E49EAE106F0E2D133D7C1CD0; Path=/; Secure; HttpOnly" -v -k --user JK -i https://smpserverip:8083/Admin/kapsel/jaxrs/KapselApp/com.mycompany.appupdate/stage -X PUT -d "[{\"platform\": \"android\",\"revisions\":[-1]}]" -H "Content-Type: application/json"
Retrieve: curl --user JK -X GET -i https://smpserverip:8083/Admin/kapsel/jaxrs/KapselApp/com.mycompany.appupdate -k
Promote: curl --header "X-CSRF-Token:C2C5E1135618958352837DBA1183F02D" --header "Cookie:X-SMP-SESSID=BD8B6793BF950AAC790BD0B48CEFFD205A2E33A5D70D14908B3B4D76C6396C99; Path=/; Secure; HttpOnly;X-SMP-SESSIDSSO=15B55914E49EAE106F0E2D133D7C1CD0; Path=/; Secure; HttpOnly" -v -k --user JK -i
https://smpserverip:8083/Admin/kapsel/jaxrs/KapselApp/com.mycompany.appupdate -X DELETE d "[{\"platform\": \"android\",\"revisions\":[-1]}]" -H "Content-Type: application/json
Delete: curl --header "X-CSRF-Token:C2C5E1135618958352837DBA1183F02D" --header "Cookie:X-SMP-SESSID=BD8B6793BF950AAC790BD0B48CEFFD205A2E33A5D70D14908B3B4D76C6396C99; Path=/; Secure; HttpOnly;X-SMP-SESSIDSSO=15B55914E49EAE106F0E2D133D7C1CD0; Path=/; Secure; HttpOnly" -v -k --user JK -i https://smpserverip:8083/Admin/kapsel/jaxrs/KapselApp/com.mycompany.appupdate/android -X DELETE d "[{\"platform\": \"android\",\"revisions\":[-1]}]" -H "Content-Type: application/json
Additional info
1.
-v : --verbose Make the operation more talkative
-k: --insecure Allow connections to SSL sites without certs (H)
-X, --request Specify request command to use
-i, --include Include protocol headers in the output (H/F)
-H, --header Pass custom header LINE to server (H)
2. If you are running HCPms or smp behind a proxy server, just add
--proxy proxyserver:proxyport in the command line
3. There is a slight difference in cookies to be passed in case of on-premise SMP than HCPms
4. 8083 is default port for Admin cockpit.If you have changed this port (while installation), make sure to use the same one in case of on-premise SMP
5. If you come across '
SSL certificate problem' , you can add
-k to turn off curl's verification of the certificate.
6. Revision version for the app(s) in NEW VERSION section is always in minus like -1 ,-2. This minus sign will not be shown in 'App Specific settings' tab but you can verify it in GET call (retrieving an hybrid app details). Same revision version (with minus sign) should be mentioned in case of moving an app from NEW VERSION to either STAGE or CURRENT.
Above write-up is done for learning purpose, will update more on further findings. A ton of thanks to Martin Grasshoff for his inputs.
There is a
documentation available on this topic, but its not up to date. It will be updated soon.