Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I download the source code of a google app engine project?

This seems like it should be very easy but I don't see a link to it anywhere.

How do I download the source code of a google app engine project?

like image 928
asdasd Avatar asked Mar 23 '10 03:03

asdasd


People also ask

How do I run Google App Engine project locally?

Running your application locally Select File > Open to open the project you want to run. Browse to the directory containing your project. Select Tools > Cloud Code > App Engine Run on a local App Engine Standard dev server.


10 Answers

Windows

appengine-java-sdk\bin\appcfg.cmd -A <your_app_id> -V <your_app_version> download_app <output-dir>

Linux

./appengine-java-sdk/bin/appcfg.sh -A <your_app_id> -V <your_app_version> download_app <output-dir>
like image 172
Ankit Avatar answered Oct 01 '22 16:10

Ankit


For completeness, using the Python implementation:

appcfg.py download_app -A $appID -V $appVersionNumber $downloadDirectory --oauth2

--oauth2 is of course optional, you can omit it and provide your email + app-specific password (or your password, and then go implement two-factor authentication right after), but it's easier, and frankly there's no reason not to.

Documentation.

like image 27
OJFord Avatar answered Oct 01 '22 16:10

OJFord


App Engine actually recently added the ability for the developer who uploaded a given app version to download its source code.

like image 20
ryan Avatar answered Oct 01 '22 14:10

ryan


IMHO, the best option today (Aug 2018) is:

Under the main menu, under Products, go to Tools -> Cloud Build -> Build history.

There, click the ID of the build you want (for me - the last one).

Then, in the opened window (Build details), click the "source" link, the download of your compressed code begins.

As simple as that.

HTH.

like image 38
Dovi Lilling Avatar answered Oct 01 '22 16:10

Dovi Lilling


As of October 2019 you can simply go to --> App Engine --> Services and in the tool dropdown select 'source' and the source code is there

like image 26
Robert Salgado Avatar answered Oct 01 '22 14:10

Robert Salgado


Posting this since none of the listed methods above didn't take me to the code (by June 2021)

You could try accessing it through;

Google Cloud Platform > Debugger > choosing the version of the Application from combo at top.

This will list the files of that version on the left pane. There is no way to download it automatically but you can copy-paste the code.

Hope you will find this helpful.

like image 21
Gayan Pathirage Avatar answered Oct 01 '22 15:10

Gayan Pathirage


Working with App engine standard using Go, the debugger isn't available yet.

How I managed to download the source code for an existing service was to use the gcloud tool.

First: Get the version id of your service using the app engine console or running: gcloud app versions list

Second: use the version and service name and run: gcloud app versions describe <versionID> --service=<service name>

the describe parameter will give you the storage locations for your source files that looks like this:

cmd/main.go:
      sha1Sum: e3fe5848c2640eca7ac3591490e1debc2d3a9b09
      sourceUrl: https://storage.googleapis.com/<project>/<file id>

Third: you can then use the storage console, using the file id, to download the files you are interested in.

like image 32
Cadet Avatar answered Oct 01 '22 15:10

Cadet


this process based on java sdk Its works for me...

  1. Download Google cloud SDK gcloud init enter image description here

  2. Follow through process of logging in using your credentials

  3. Enter following command from SDK

    C:\Program Files (x86)\Google\appengine-java-sdk-1.9.49\bin

enter image description here

  1. Enter Following command to download source code

    appcfg.sh -A [YOUR_APP_ID] -V [YOUR_APP_VERSION] download_app [OUTPUT_DIR]

    Eg: appcfg.sh -A my-project-name-1234 -V 2 download_app C:\Users\india\Desktop\my project

    Note: this progress based on java-appengine sdk so we use appcfg.sh instead of appcfg.py

like image 20
manoz Avatar answered Oct 01 '22 16:10

manoz


check if your app is uploaded with same email id that is in your app engine. if you are not sure then in app engine > control > Clear deployment credentials and then click on any project, deploy to sign in again then use this

appcfg.py download_app -A {app id from google app engine} -V {1} "{c:\path}" --oauth2_credential_file=C:\Users\{your account name}/.appcfg_oauth2_tokens

change all {} to your needs

like image 38
Zain Ullah Muhammad Avatar answered Oct 01 '22 16:10

Zain Ullah Muhammad


Things have changed since this question was asked so I'm adding an updated answer. Note that this only applies to GAE Standard Environment

Google has deprecated appcfg.py and so the previous responses appcfg.py download_app no longer works.

  1. gcloud which is the SDK in use (it replaced appcfg) does not have the functionality to download your source code.
  2. When you deploy your app via gcloud app deploy, it copies your source code to a bucket. The default bucket is staging.<project_name>.appspot.com. Your files will stay in this bucket for a maximum of 15 days before they are deleted. You can modify the rule so that the files are retained for longer or less time.
  3. The file names in the bucket are encoded so you can't figure out what each file is unless you open it (i.e. download it). Google has a mapping of the encoded names to the original file names. To get this mapping, you run the gcloud app versions describe command and it will list the file names and their encoded names. To download the files, you have to manually click each url one by one. So essentially, you have to download each file manually and then use the mapping to rename them (or open the file, check the content and then rename them). Also note that downloading the files manually will not maintain the folder structure in which they were uploaded.
  4. If you do not wish to go through all of the above hassles (imagine having to manually open each url for each file if you have a small to mid-sized project which has hundreds of files), our App - https://nocommandline.com - now supports downloading source code from the default bucket - staging.<project_name>.appspot.com (so far as your files are still there which means any deployment i.e update not older than 15 days from your current date unless you previously increased the deletion age on your staging bucket's lifecycle page).
  5. In simple terms, you enter your project name, the version number and our App will take care of retrieving the original file name to encoded name mapping, automatically downloading the files and renaming them to the original names, while maintaining the folder structure. For more information, refer to https://nocommandline.com/help/#faq_download_source_code_from_gae.
like image 36
NoCommandLine Avatar answered Oct 01 '22 15:10

NoCommandLine