I am trying to push the AEM package from Dev to QA via a custom workflow process step, and it should not be installed in QA.
When I used Replicator to achieve this, it installed the package in QA.
When I used Curl Command It was giving exit code 26—https://everything.curl.dev/usingcurl/returns
Kindly help me out.
Thanks in advance !!!
//Curl Command for Uploading the Package
ProcessBuilder processBuilder = new ProcessBuilder("curl", "-u", "admin:admin", "-F", "package=@" + packagePath, " http://localhost:4503/crx/packmgr/service/.json/?cmd=upload");
Process process = processBuilder.start();
process.waitFor();
int exitCode = process.exitValue();
process.destroy();
Solved! Go to Solution.
Views
Replies
Total Likes
@Shiv_Prakash_Patel You are using wrong way of command please check
package=@/etc/packages/my_packages/sample.zip
It should be
package=@"/etc/packages/my_packages/sample.zip"
double quote after @
Passing you servlet which I have tested along with result.
@Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { try { //Curl Command for Uploading the Package String[] command = {"curl", "-u", "admin:admin", "-F", "cmd=upload", "-F", "force=true", "-F", "package=@\"/Users/ssai/Projects/mysite/ui.apps/target/mysite.ui.apps-1.0.0-SNAPSHOT.zip\"", "http://localhost:4502/crx/packmgr/service/.json"}; ProcessBuilder processBuilder = new ProcessBuilder(command); Process process = processBuilder.start(); process.waitFor(); int exitCode = process.exitValue(); process.destroy(); } catch (JSONException | InterruptedException e) { e.printStackTrace(); } }
Why don’t you use Java PackageManager API instead, it’s recommended- please check ready to use solution:https://www.albinsblog.com/2018/01/how-to-upload-and-install-packages-through-java-api-in-aem.html?m...
@Shiv_Prakash_Patel Try out the below curl command from java.
String[] command = {"curl", "-H", "Accept:application/json", "-u", username+":"+password , "-F", "package=@" + packagePath, "http://localhost:4503/crx/packmgr/service/.json/?cmd=upload"};
Thanks
Hi @ShaileshBassi ,
I have tried with above curl command but result is same (still getting exit code - 26).
Thanks
Hi @Shiv_Prakash_Patel ,
Let's try these two?
curl -u <user>:<password> -F cmd=upload -F force=true
-F package=@test.zip http://localhost:4503/crx/packmgr/service/.json
curl -u admin:admin -F file=@"name of zip file" -F name="name of package"
-F force=true -F install=false http://localhost:4503/crx/packmgr/service.jsp
Hi @SantoshSai ,
I have tried both in the AEM servlet. It is not working and giving exit code 26. The same curl command works fine with the terminal.
Have you tried this in a servlet or workflow process step? If so, please correct me.
I am using the below code in a servlet.
Regards!
//Curl Command for Uploading the Package
String[] command = {"curl", "-u", "admin:admin", "-F", "cmd=upload", "-F", "force=true", "-F", "package=@/etc/packages/my_packages/sample.zip", "http://localhost:4503/crx/packmgr/service/.json"};
ProcessBuilder processBuilder = new ProcessBuilder(command);
Process process = processBuilder.start();
process.waitFor();
int exitCode = process.exitValue();
process.destroy();
@Shiv_Prakash_Patel You are using wrong way of command please check
package=@/etc/packages/my_packages/sample.zip
It should be
package=@"/etc/packages/my_packages/sample.zip"
double quote after @
Passing you servlet which I have tested along with result.
@Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { try { //Curl Command for Uploading the Package String[] command = {"curl", "-u", "admin:admin", "-F", "cmd=upload", "-F", "force=true", "-F", "package=@\"/Users/ssai/Projects/mysite/ui.apps/target/mysite.ui.apps-1.0.0-SNAPSHOT.zip\"", "http://localhost:4502/crx/packmgr/service/.json"}; ProcessBuilder processBuilder = new ProcessBuilder(command); Process process = processBuilder.start(); process.waitFor(); int exitCode = process.exitValue(); process.destroy(); } catch (JSONException | InterruptedException e) { e.printStackTrace(); } }
Why don’t you use Java PackageManager API instead, it’s recommended- please check ready to use solution:https://www.albinsblog.com/2018/01/how-to-upload-and-install-packages-through-java-api-in-aem.html?m...
Hi @SantoshSai ,
Thank you so much for suggesting the code changes. I made the changes and it is working fine with Windows or Mac file paths.
Even though I added a double quote after @, it is not working with AEM relative path or full path.
Please see the below screenshot.
I can use JcrPackageManager to upload the package, but for that I need a session of QA AEM instance in Dev.
//Getting JcrPackageManager with the help of session
JcrPackageManager jcrPackageManager = PackagingService.getPackageManager(session);
//Package upload with help of JcrPackageManager
JcrPackage inputPackage = jcrPackageManager.upload(new File(packagePath), false, true, "sample.zip");
Basically, I am trying to migrate a package from one AEM instance to another AEM instance in the approval workflow. I tried to get the session of AEM Publish into AEM Author but getting null Repository - https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/access-jcr.html?la...
It suggest us to use jackrabbit-standalone-2.4.0.jar, but it didn't work when I downloaded the jar and uploaded it in AEM Author. If I will use same jar and code with standalone java project It will work.
The recommended solution, which you are suggesting, uses the same instance session and also uploads the package to it.
Regards !
Views
Likes
Replies
Views
Likes
Replies