Building Frameworks and Applications with Jenkins

Version 53.1 by David Avendasora on 2012/03/05 03:24
Warning
For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.

WOJenkins

The easiest way to get started with using Jenkins to build your WebObjects projects is to make use of WOJenkins. WOJenkins is a set of shell scripts and Jenkins job configurations that should fit most WebObjects projects out-of-the-box, but they can also be modified to fit specific needs.

Warning

Prerequisites

To make use of WOJenkins, you will need all of the following:
# A running Jenkins server. Ideally setup and configured using the [Installing and Configuring Jenkins|WO:Installing and Configuring Jenkins Build Server] instructions.
# [Git SCM installed|http://wiki.wocommunity.org/display/WO/Getting+Started+with+Git] on the Jenkins server.
# The Jenkins [Git Plugin|https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin] installed
# The Jenkins [Multi SCM Plugin|https://wiki.jenkins-ci.org/display/JENKINS/Multiple+SCMs+Plugin] installed

Installing WebObjects and Project Wonder Frameworks

Before you can build your framework or application you will need to have WebObjects, Project Wonder and woproject.jar installed on your Jenkins server. The WOJenkins scripts and job configurations depend upon all three of them being installed in the JENKINSHOME/WOFrameworksRepository directory. 

The quickest way to install everything you need is by using WOJenkins itself! Specifically, by using the WOJenkins InstallWOAndWOnder job configuration.

  1. Change directories into JENKINSHOME/jobs

cd /Users/Shared/Jenkins/Home/jobs/
  1. Clone job configuration from github.com repository

git clone https://github.com/avendasora/WOJenkins_Job_InstallWOAndWOnder.git Install_WebObjects_And_Wonder
  1. Set correct ownership and permissions - If you used the Mac OSX Jenkins installer, the user and group that it will be using are both "daemon"

sudo chown -R daemon:daemon Install_WebObjects_And_Wonder/
  1. Open Jenkins and tell it to reload the configuration files so it will see the new job.

    • From within Jenkins user interface, navigate to: Jenkins -> Manage Jenkins -> Reload Configuration from Disk
    • Call the reload URL: http://localhost:8080/reload - this link should work for a default install if you haven't turned on any security.
  1. Open the new Job.
    You should see a new job called InstallWebObjectsAndWonder. You'll see the following options:
    1. The version of WebObjects to be downloaded from Apple and installed in JENKINSHOME/WOFrameworksRepository/WebObjects
    2. The branch of Project WOnder that should be built after cloning the Project Wonder github repository.
    3. The build target for wonder that should be run. Usually you'll want the default of just the frameworks.
Warning
This job may take a long time to run the first time

Depending upon the speed of your internet connection, this job may take a long time to complete (several minutes to several hours or more) the first time it is run since it downloads the WebObjects installer from Apple, and clones the entire Project Wonder Git repository (including _all_ the commit history back to the beginning of time). Subsequent runs should be much faster as the job will not download or install WebObjects again and only new commits will be pulled from the Project Wonder Git repository.

Troubleshooting WebObjects & Wonder Install
  • If you get the following error:

/var/folders/zz/zyxvpxvq6csfxvn_n0000004000001/T/hudson6582791585070315951.sh: line 2: /Users/Shared/Jenkins/Home/jobs/InstallWOAndWOnder/workspace/WOJenkins/Install/WebObjects/installWebObjects.sh/Users/Shared/Jenkins/Home/jobs/InstallWOAndWOnder/workspace/WOJenkins/Build/Wonder/WorkspaceSetupScripts/Git/setupWonderWorkspace.sh: Not a directory
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Check the Execute Shell Script task in the Build section of the job configuration in Jenkins to make sure the carriage return was not stripped from between the two scripts when it was imported into Jenkins. The task should look like exactly like this (with two commands, each one on its own line):


${WORKSPACE}/WOJenkins/Install/WebObjects/installWebObjects.sh
${WORKSPACE}/WOJenkins/Build/Wonder/WorkspaceSetupScripts/Git/setupWonderWorkspace.sh
  • If you did not have the Multi SCM plugin installed Jenkins will break the job by removing the tasks to clone WOJenkins and Project WOnder. To fix it:
    1. Install the plugins under Jenkins -> Manage Jenkins -> Manage Plugins
    2. Revert the changes made to the config.xml file by Jenkins by calling git reset --hard HEAD in the job directory 
    3. Tell Jenkins to Reload Configuration from Disk as shown above.

Building an application or a framework

Now that WebObjects and Wonder are installed for Jenkins, you are ready to build an application or framework (or both). Again, we will use a script from David as a startup point.

  • Clone the script somewhere:
git clone https://github.com/avendasora/WOJenkins_Job_WOProject_Git.git
  • Go into the WOJenkinsJobWOProjectGit directory that was created with the previous command:
cd WOJenkins_Job_WOProject_Git
  • Add the config into Jenkins. You can add it by doing a POST request to Jenkins, like this:
curl -v --user youruser:yourpassword -H "Content-Type: text/xml" -s --data "@config.xml" http://yourjenkinsserver:8080/createItem?name=YourProjectName

Replace youruser and yourpassword with your Jenkins credentials and replace yourjenkinsserver with the DNS name (or IP address) of your Jenkins installation. Replace YourProjectName with the name of the job (ERGroupware, SimpleBlog, whatever your project name is).

We need to make a couple of modifications to the configuration of the new Jenkins job.

  • First: delete the PROJECTNAME string parameter. In the steps below, we are going to hardcode the project name in the job configuration.
  • One of the SCM repositories is named $PROJECTGITREPOSITORY. Click the Advanced button (see screenshot)
    SafariScreenSnapz144.jpg
  • For Local subdirectory for repo, change the value to Projects/<InsertYourProjectNameHere>, and change the value of Unique SCM name to the name of your project.
  • In the Build section, the path to setupWonderProjectWorkspace.sh is wrong. Change it to:
${WORKSPACE}/WOJenkins/Build/WonderProjects/WorkspaceSetupScripts/setupWonderProjectWorkspace.sh
  • In the Invoke Ant section, the properties file should be jenkins.build.properties, so replace /Root/build.properties with /Root/jenkins.build.properties.
  • Click on the Advanced button related to the Ant task. Change the value of Build File to Projects/<InsertYourProjectNameHere>/build.xml, and change the value of Properties to Projects/<InsertYourProjectNameHere>/

You are now readying to build your project with Jenkins Check the console for the job for any errors.

Warning

If your project is missing some default folders, like _Libraries_ or _WebServerResources_, woproject won't be able to build the project. Make sure that those directories are in your Git repository.

Unknown macro: color. Click on this message for details.

/var/lib/jenkins/jobs/ERGroupware/workspace/Root/Local/Library/WebObjects/Extensions does not exist.

Unknown macro: color. Click on this message for details.

ln -s /var/lib/jenkins/WOFrameworksRepository/WebObjects/5.4.3/Local/Library/WebObjects/Extensions /var/lib/jenkins/jobs/<NameOfYourProject>/workspace/Root/Local/Library/WebObjects/Extensions

Building frameworks and applications

With the sample configuration, you can also build frameworks and applications at the same time. The trick is to add another SCM repository and another Ant task to the configuration, and for frameworks, the Ant task should call the install task instead of build. The Ant task to build a framework should be called BEFORE the task to build the application