2017-11-24

Authorize Jenkins to Google App Engine

Authorize Jenkins to Google App Engine

I usually want everything in the cloud including my Jenkins server. I've been using Bitnami for this but each time I've the same problem of authorize since in the middle of the build Google asks Jenkins to follow a URL and authorize and then paste a key.

Bitnami

Bitnami is an excellent cloud service where you can run services in the cloud. I choose an installation in Europe using Google Compute API and with a Jenkins Image.
When creating your Virtual machine with Jenkins you start an installation wizard where you can select the most common plugins like Maven.

Preparation

It's necessary to know where Maven is installed. This is a simple way to do it without using a console.
  1. Make sure you have installed "Maven Integration Plugin" 
  2. Create a Freestyle project and add a "Execute shell" buildstep with the following command:
    find / -name "mvn"
  3. Check the console for Maven installation folder

Maven Google App Engine Project

Let's create the Maven Google App Engine Project and authorize!
  1. Create a "Freestyle project"
  2. Enter project details like Source code and build triggers. At "Build step" add "Execute bash" as "Build step". Run maven with:
    /opt/bitnami/apps/jenkins/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven/bin/mvn appengine:update
  3. This will fail since the App Engine plugin will stop for a authorization. It prints an URL which Jenkins cannot open. Follow the link in your browser and sign in using your Google account. Copy the key you receive.
  4. Update your project and change the command to:
    echo "key-you-got-from-your-browser" | /opt/bitnami/apps/jenkins/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven/bin/mvn appengine:update
  5. Run the project and you should be authorized!
What happens is that your key is entered when Maven stops for input.