Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To change port configurations for Jenkins instead, modify the jenkins.xml file found in the Jenkins main folderdirectory. See the section below:

Code Block
languagexml
titlejenkins.xml
collapsefalse
  <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080</arguments>

...

  • if you don't have Ant installed, in "Ant" section add a new installation, give it a name and check "Install automatically".
  • "# of executors": set it to 1 for now; this limits the concurrent executing jobs to 1. In the future if you want to set-up a more advanced configuration you can configure multiple jobs to run simultaneously (for example for multiple solutions) - just make sure they use separate resources so that they don't affect each other (for example separate Servoy Installations).
  • "Jenkins URL": to the real URL that will be used by users to access the Jenkins server. (for example this will appear as part of notification emails)
  • "System Admin e-mail address": use your email address.
  • "E-mail Notification": configure this as needed. By default it will try to use the localhost SMTP server which will already be working probably on some linux machines. You can also test the configuration by sending a test email.
  • hit the "Save" button.

Step-by-step configuration for using it with Servoy

In the SVN repository we will have Servoy solutions that need to be automatically tested using import-smart-client and a solution to be automatically tested in mobile-test-client. The ANT scripts used by Jenkins to automatically export and test Servoy solutions will be in a separate project "antRunner" in the same SVN repository.

Step 1 -- Sample workspace and SVN content

Sample workspace

First we have to set-up sample SVN contents. This can be done on any computer with access to the SVN server, not necessarily on the same computer as Jenkins.

Here is the sample Servoy workspace that we will use: SoftwareFactory_Jenkins_Workspace.zip.

Unzip. Start Servoy Developer and switch workspace to the unzip location (File -> Switch Workspace).

Go to File -> Import -> General -> Existing Projects into Workspace. At "Select root directory" click the browse button then enter (it should select the workspace directory). Check all projects - you should see all (8) projects that you previously unzipped. Click finish.

You can now have a look at the sample solutions and run tests on them from developer.

Commit to your SVN repository

Install Subclipse plugin in Servoy Developer (Help -> Install New Software) if you haven't already done so.

Open Navigator view (Window -> Show view -> Other -> General -> Navigator). Select all projects and right click -> Team -> Share Project -> SVN.

...

  • download and unzip ant-contrib (for example I downloaded and unzipped ant-contrib-0.6-bin.zip) from http://sourceforge.net/projects/ant-contrib/files/ (project page is http://ant-contrib.sourceforge.net/). Check "Environment variables" in Jenkins configuration page and set a key-value pair with key "ANT_CONTRIB_JAR" (drop the quotation marks) and value containing the full path to where the downloaded ant-contrib*.jar is located in the unzipped contents - including file name.
  • "# of executors": set it to 1 for now; this limits the concurrent executing jobs to 1. In the future if you want to set-up a more advanced configuration you can configure multiple jobs to run simultaneously (for example for multiple solutions) - just make sure they use separate resources so that they don't affect each other (for example separate Servoy Installations).
  • "Jenkins URL": to the real URL that will be used by users to access the Jenkins server. (for example this will appear as part of notification emails)
  • "System Admin e-mail address": use your email address.
  • "E-mail Notification": configure this as needed. By default it will try to use the localhost SMTP server which will already be working probably on some linux machines. You can also test the configuration by sending a test email.
  • hit the "Save" button.

Step-by-step configuration for using it with Servoy

In the SVN repository we will have Servoy solutions that need to be automatically tested using import-smart-client and a solution to be automatically tested in mobile-test-client. The ANT scripts used by Jenkins to automatically export and test Servoy solutions will be in a separate project "antRunner" in the same SVN repository.

Step 1 -- Sample workspace and SVN content

Sample workspace

First we have to set-up sample SVN contents. This can be done on any computer with access to the SVN server, not necessarily on the same computer as Jenkins.

Here is the sample Servoy workspace that we will use: SoftwareFactory_Jenkins_Workspace.zip.

Unzip. Start Servoy Developer and switch workspace to the unzip location (File -> Switch Workspace).

Go to File -> Import -> General -> Existing Projects into Workspace. At "Select root directory" click the browse button then enter (it should select the workspace directory). Check all projects - you should see all projects that you previously unzipped. Click finish.

You can now have a look at the sample solutions and run tests on them from developer.

Commit to your SVN repository

Install Subclipse plugin in Servoy Developer (Help -> Install New Software) if you haven't already done so.

Open Navigator view (Window -> Show view -> Other -> General -> Navigator). Select all projects and right click -> Team -> Share Project -> SVN.

For each project click on "Share project" button and add it to your SVN repository (you can use an existing SVN repository or just make a SVN test server with SVN server software such as VisualSVN). I added it to something like http://myhost:[svnServerPort]/svn/jenkinsSolutions/trunk/[project_name]. For the first project you will have to choose "create repository (connection)" -> "http://myhost:[svnServerPort]/svn/jenkinsSolutions" and folder directory "trunk/demo_ipAddressValidator". For the rest you will choose an existing SVN repository (the connection you just created).

...

Download and install Servoy Developer. It's best to use a clean installation (no extra eclipse plugins) to avoid potential problems generated by other eclipse plugins (for example installing Subclipse in this developer can cause a hang as that plugin is trying to access the UI while blocking a resource - in the headless solution export environment).

Step 3 -- Configure

...

Smart Client Jenkins job

Your Jenkins server should be able to access the SVN server you just committed to - in case you didn't use the same computer. Navigate to the Jenkins server page in your browser.

...

Under "Build" click on "Add build step". Choose "Invoke Ant". Select the version you configured to auto-install at "Other things to configure" above. Click on "Advanced". In "Targets" type main_smart. In "Build file" type antRunner/jenkins_build.xml. In "Properties", expand the field (arrow down button) then type:

Code Block
languagejava
work.servoy.install.dir=[path_to_your_separate_Servoy_developer_installation]

...


WORKSPACE=${WORKSPACE}

...


ANT_CONTRIB_JAR=${ANT_CONTRIB_JAR}

If you are on windows use '/' or '\\' instead of '\' in that path. For example "work.servoy.install.dir=f:/ServoyInstalls/Servoy_7.3".

...

After a build finishes you should have 4 files in your build/Status/Build Artifacts - one showing the test results and 3 Servoy log files showing what happened during export/import/test.

Step 4 -- Configure

...

Mobile Client Jenkins job

For mobile testing we will need Chrome browser installed (other browsers, even mobile device simulations/emulations can be used, check the help page of Servoy mobile test runner for details), a copy of SeleniumServer jar downloaded (http://docs.seleniumhq.org/download/) and a copy of Chrome selenium driver downloaded/extracted (http://code.google.com/p/chromedriver/downloads/list). The mobile test solution will automatically be deployed in Servoy Developer's bundled Tomcat server (the one at [work.servoy.install.dir]) and started using Selenium in the Chrome browser to run tests - by the mobile servoy test suite. If the tests pass, the actual mobile solution will be exported and copied to/deployed in [deploy.servoy.install.dir]'s bundled Tomcat.

...

Under "Build Triggers" select "Poll SCM" and in "Schedule" field use H/3 * * * *   (every 3 minutes, let Jenkins choose the minute when it checks for SVN changes to avoid overcrowding in the future). You can increase that to decrease requests on the SVN server. If changes are found Jenkins will trigger the build. If you want a check every minute use * * * * *.

...

If you are on windows use '/' or '\\' instead of '\' in that path. For example:

Code Block
languagejava
work.servoy.install.dir=f:/ServoyInstalls/Servoy_7.3[path_to_your_separate_Servoy_developer_installation]
deploy.servoy.install.dir=f:/ServoyInstalls/Servoy_7.3_deployment[path_to_your_deployment_Servoy_developer_installation]
webdriver.chrome.driver=f:/Selenium/Drivers/Chrome/[path_to_chromedriver.exe_that_was_downloaded_above]
selenium.server.jar=f:/Selenium/selenium-server-standalone-2.33.0.jar

The deployment installation of Servoy can be the one that "Install/Start Servoy Server Importer" step will use.

Under "Post-build Actions":

  • add "Archive the artifacts" with this in "Files to archive": antRunner/jsunit_results/junit-noframes.html, antRunner/jsunit_results/smart_import_test_client_log.txt, antRunner/jsunit_results/workspace_exporter_app_server_log.txt, antRunner/jsunit_results/workspace_exporter_workspace_log.txt
  • add "Publish JUnit test result report" with "Test report XMLs" set to: antRunner/jsunit_results/TESTS-TestSuites.xml
  • add "E-mail notification" and type your email address in "Recipients" field.

Click on "Save" and go back to Jenkins dashboard. The new job should automatically start in under 3 minute (or you can start it manually using the "play" icon next to it). It should export/run tests in chrome/export normal solution/copy it to deployment Servoy installation - with 2 test failures. To make the tests pass fix the regular expression as hinted by the comment in solution demo_ipAddressValidator, in the globals scope, and then commit the change to SVN.

If anything goes wrong you can click on your job's name then on the left side you see a list of builds. Click on the build that failed and you can see it's details (time/status/tests/console/...).

After a build finishes you should have 4 files in your build/Status/Build Artifacts - one showing the test results and 3 Servoy log files showing what happened while exporting/testing.

Code Block
languagejava
work.servoy.install.dir=[path_to_your_separate_Servoy_developer_installation]
deploy.servoy.install.dir=[path_to_your_deployment_Servoy_developer_installation]
webdriver.chrome.driver=[path_to_chromedriver.exe_that_was_downloaded_above]
selenium.server.jar=[path_to_downloaded_selenium_server_jar]
WORKSPACE=${WORKSPACE}[path_to_downloaded_selenium_server_jar]
WORKSPACE=${WORKSPACE}
ANT_CONTRIB_JAR=${ANT_CONTRIB_JAR}

For example:

Code Block
languagejava
work.servoy.install.dir=f:/ServoyInstalls/Servoy_7.3
deploy.servoy.install.dir=f:/ServoyInstalls/Servoy_7.3_deployment
webdriver.chrome.driver=f:/Selenium/Drivers/Chrome/chromedriver.exe
selenium.server.jar=f:/Selenium/selenium-server-standalone-2.33.0.jar
WORKSPACE=${WORKSPACE}
ANT_CONTRIB_JAR=${ANT_CONTRIB_JAR}

The deployment installation of Servoy can be the one that "Install/Start Servoy Server Importer" step will use.

Under "Post-build Actions":

  • add "Archive the artifacts" with this in "Files to archive": antRunner/jsunit_results/junit-noframes.html, antRunner/jsunit_results/smart_import_test_client_log.txt, antRunner/jsunit_results/workspace_exporter_app_server_log.txt, antRunner/jsunit_results/workspace_exporter_workspace_log.txt
  • add "Publish JUnit test result report" with "Test report XMLs" set to: antRunner/jsunit_results/TESTS-TestSuites.xml
  • add "E-mail notification" and type your email address in "Recipients" field.

Click on "Save" and go back to Jenkins dashboard. The new job should automatically start in under 3 minute (or you can start it manually using the "play" icon next to it). It should export/run tests in chrome/export normal solution/copy it to deployment Servoy installation - with 2 test failures. To make the tests pass fix the regular expression as hinted by the comment in solution demo_ipAddressValidator, in the globals scope, and then commit the change to SVN.

If anything goes wrong you can click on your job's name then on the left side you see a list of builds. Click on the build that failed and you can see it's details (time/status/tests/console/...).

After a build finishes you should have 4 files in your build/Status/Build Artifacts - one showing the test results and 3 Servoy log files showing what happened while exporting/testing.

Customize Jenkins jobs to suite your set of test solutions

Congratulations! Now you should have a working sample Mobile Client test job and a working sample Smart Client test job.

Next you will probably want to configure the same for your own test solutions. Here is how you can do that.

Basic customization

All the steps for creating jobs for your own solutions are almost identical to the sample jobs (see "Configure Smart Client Jenkins job" and "Configure Mobile Client Jenkins job" above). What you should do differently:

  • Under "Source Code Management", instead of configuring sample SVN contents, configure the location of your own solutions to be checked out. Make sure the resulting job workspace contents are similar (after checkout the job workspace directory should contain directly the solution/resources project directories).
  • Adjust "Abort the build if it's stuck" value depending on how long you expect your test job to run.
  • At "Build" -> "Add build step" -> "Invoke Ant" -> "Advanced" -> "Properties" -> expanded - add to that text-area the following properties to specifiy the names of the root solutions relevant for your test job:
    • in case of Smart Client job - replace sample tests root solution names below with your own; comma separated list:

      Code Block
      languagejava
      smart_test_solutions      = solution1,solution2
    • in case of Mobile Client job - replace sample root solution names below with your own; comma separated lists:

      Code Block
      languagejava
      mobile_test_solutions     = demo_ipAddressValidatorTester
      mobile_service_solutions  = demo_ipAddressValidatorTester_service
      mobile_to_deploy          = demo_ipAddressValidator
      mobile_to_deploy_services = demo_ipAddressValidator_service
  • Change the "antRunner/servoy.properties" file as needed by your solutions (define servers and other needed changes; the repository server can be a Hslq (in memory) server to always import clean or you can change it to a persistent server as well).

Advanced customization

The "Basic customization" steps should be enough for most cases. If you have the need to control more aspects like using separate servoy.properties for exporter and import test clients, changing arguments used by exporter and import test client or modifying more timeouts that don't suit your solutions it can be done. Here are a few more things that you can do (of course you could do much more with what Jenkins or ant have to offer):

  • customize the job ant build's behavior by defining more properties in "Build" -> "Add build step" -> "Invoke Ant" -> "Advanced" -> "Properties" -> expanded. Customizable properties are listed in the first section of "antRunner/export_and_test.properties" and are explained in their comments preceding each one:

    Code Block
    languagejava
    # ------------------------------------------------------------------------------------------------
    # Properties that you should set in Jenkins job configurations (ant advanced config; they will ---
    # be available to ant and also have precedence over what is defined in this file               ---
    # ------------------------------------------------------------------------------------------------
    
    # Servoy developer installation that will be used for exporting/testing (a separate install
    # is recommended for each Jenkins job in case multiple jobs are configured to run concurrently)
    
    work.servoy.install.dir             = [your_jenkins_dedicated_servoy_installation_dir]
    work.servoy.install.url             = http://localhost:8080
    
    # Paths to other downloaded tools that we need
    
    webdriver.chrome.driver             = [path_to_the_downloaded_selenium_chrome_driver_executable]
    selenium.server.jar                 = [path_to_downloaded_selenium_server_jar]
    
    # Solutions to be exported and then tested;
    # multiple solutions can be specified via a comma separated list of solution names
    
    smart_test_solutions                = solution1,solution2
    
    mobile_test_solutions               = demo_ipAddressValidatorTester
    mobile_service_solutions            = demo_ipAddressValidatorTester_service
    
    mobile_to_deploy                    = demo_ipAddressValidator
    mobile_to_deploy_services           = demo_ipAddressValidator_service
    
    # If you are using a Servoy version >= 7.3 please uncomment or set the following (otherwise leave it
    # commented out; setting it to "false" or "nope" is not the same); the old way should work on 7.3 or
    # newer as well, but not the other way around; new way only only gets rid of some unneeded exporter
    # initialization time
    
    # work.servoy.install.7.3.or.higher = yep
    
    # 1 hour time-out; edit this as needed - depending on how long it usually takes for your solution tests to run (should probably be lower in most cases)
    
    test.timeout                           = 3600000
    
    # Uncomment the following line/set this if you want passed exports generated by previous build
    # to be deleted at the beginning of each build cycle
    
    #always_clean_passed_exports        = yep
    
    # For Sauce Labs test cloud (testing mobile clients); also uncomment relevant lines in
    # "run_mobile_client_tests_if_exported_ok" target of jenkins_build.xml; other changes might be needed as well, but this is the main idea
    
    #sauce.labs.user                    = [your Sauce Labs user here]
    #sauce.labs.token                   = [access token goes here]
    #sauce.labs.selenium.url            = http://${sauce.labs.user}:${sauce.labs.token}@localhost:${SAUCE_ONDEMAND_PORT}/wd/hub
    # define a timeout for sauce labs to not require additional Selenium commands for a solution (set to 1.5 min; should be updated for how long your test can possibly take to run, but not much higher)
    #sauce.labs.selenium.idle-timeout   = 90
    
    # If you want your mobile solutions deployed to a Servoy server after testing is done,
    # uncomment / set values as in the following two lines and change the value of
    # servoy.deploy.install.dir to point to it; passed .war files will be copied to deploy.webapps.dir location.
    
    #deploy.servoy.install.dir          = [your_mobile_war_deployment_servoy_installation]
    #deploy.webapps.dir                 = ${deploy.servoy.install.dir}/application_server/server/webapps
    
    # WORKSPACE property is normally already set by Jenkins in job build step
    # ANT_CONTRIB_JAR is normally already set if you followed all the steps in "Building a Software Factory" WIKI
    # page; it's set as a system property in global Jenkins configuration - environment variables
    
    #WORKSPACE                          = [if_not_set_by_Jenkins_you_can_configure_it_as_well]
    #ANT_CONTRIB_JAR                    = [if_not_set_in_Jenkins_config_as_environment_variable_you_can_configure_it_as_well]
  • workspace exporter arguments (you should have available all the options present in UI Solution Export Wizard) can be customized by modifying "antRunner/export_and_test.xml" macrodefs "export-solution" and "export-mobile-solution". You can see a list of available command line arguments in a console window by executing "[your_Servoy_installation]/developer/exporter/export.bat -help" and "[your_Servoy_installation]/developer/exporter/mobile_export.bat -help";
  • smart test client and mobile test client arguments (which are actually system properties sent to a junit test suite) can be customized by modifying "antRunner/export_and_test.xml" macrodefs "run-smart-client-tests" and "run-mobile-client-tests". You can see a list of available arguments by commenting out the "<!--arg value="-help" /-->" lines in these marcrodefs and creating/executing an ant task that calls them from the command line (or alternatively just comment out those lines in a Jenkins job and check the job build's console - after it is executed).