Passing your credentials in order to deploy to Google App Engine with Ant

If you use the example ant script¬†provided by Google you’ll face the following error:

Your authentication credentials can't be found and may have expired.
Please run appcfg directly from the command line to re-establish your credentials.

Sure, you can run appcfg.sh from the console, and login and all will be fine next time. Well, for 24 hours before your credentials are booted from the cache.

Here’s my ant target that does the same thing but takes the credentials interactively using the input task.

<target name="deploy-app" description="Uploads and deploys the application to App Engine.">
    <input message="Enter email" addproperty="gae-email"/>
    <input message="Enter password :- " addproperty="gae-password">
        <handler type="secure"/>
    </input>

    <!-- Call dependencies here rather than with 'depends' attribute to get input first -->
    <antcall target="test" />

    <java classname="com.google.appengine.tools.admin.AppCfg" inputstring="${gae-password}"
            classpath="${sdk.dir}/lib/appengine-tools-api.jar" fork="true" failonerror="true">
        <arg value="--email=${gae-email}" />
        <arg value="--passin" />
        <arg value="update" />
        <arg value="war" />
    </java>
</target>

Obviously, if you want to run this target from your CI server then you’ll need to populate the email and password properties in some other way.

 

Leave a Reply

Your email address will not be published. Required fields are marked *