1

Is there a way to download the deployed War from cloud foundry? I want to explode the war and check if the property files in the war are correct.

Punter Vicky
  • 15,954
  • 56
  • 188
  • 315
  • Why? You uploaded the war for deployment, why download it? – M. Deinum Aug 28 '15 at 17:46
  • The code is fetched from git by an automated process maintained by a different team. The code is working fine locally , but I am suspecting that the process is not fetching necessary config files. Hence I thought of verifying it by downloading the war file built by the automated process. – Punter Vicky Aug 28 '15 at 17:52

2 Answers2

4

There is no direct way to download your application from a running cloud foundry container. However, you can use the cf files <appname> [path] command to explore and even download one file at a time.

cf files ramhellojava app
Getting files for app ramhellojava in org ....
OK

.java-buildpack/                             -
.java-buildpack.log                     136.3K
META-INF/                                    -
WEB-INF/                                     -
images/                                      -
index.html                                773B
index.js                                  1.1K
style.css                                 1.1K
Ram Vennam
  • 3,536
  • 1
  • 12
  • 19
  • 1
    To expand on Ram's answer, apps are not uploaded to CF in war/jar form. Any war, jar, or zip file provided to the cf CLI or other tooling is exploded and the exploded contents are uploaded one file at a time. Only the top level archive file is exploded, any jar files included in the archive are uploaded as-is. – Scott Frederick Aug 29 '15 at 14:56
  • Or you could use a plugin http://stackoverflow.com/questions/21421474/is-it-possible-to-download-all-files-of-an-application-in-cloud-foundry – Rishabh Aug 30 '15 at 00:42
  • Unfortunately I am using PCF 7.0 and the cf files command has been removed in this version. – KurioZ7 Dec 02 '21 at 10:14
3

First thing...

Is there a way to download the deployed War from cloud foundry?

The WAR file is not uploaded to Cloud Foundry. The cf cli will look at the WAR file and extract everything from it. It does not upload the file as a whole, but the individual files in it. It's a minor difference, but worth noting because the WAR file itself doesn't exist on the server, just it's contents.

I want to explode the war and check if the property files in the war are correct.

If you're looking for an individual file then as mentioned previously cf files is one way to go. Alternatively you could use Eclipse w/the CF plugin. That allows you to browse files via a GUI.

If you need lots of files or want the whole app, a better option is to download the droplet that's being used to run your app. As long as your application finished staging successfully (i.e. the build pack ran and finished), you should be able to download the droplet that was built by CF. That should contain amongst other things your application code.

Ex:

$ cf app <app-name> --guid
2836d5fe-35f7-4409-b27b-4ed308152bb4
$ cf curl /v2/apps/2836d5fe-35f7-4409-b27b-4ed308152bb4/droplet/download > my-droplet.tar.gz
Daniel Mikusa
  • 13,716
  • 1
  • 22
  • 28