Date: Fri, 29 Mar 2024 09:18:26 +0000 (UTC) Message-ID: <2017488115.10995.1711703906740@911f0a1bad02> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_10994_609118526.1711703906740" ------=_Part_10994_609118526.1711703906740 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This is a quote from http://jenkins-ci.org/cont= ent/about-jenkins-ci:
"In a nutshell Jenkins CI is the leading open-source continuous integrat= ion server. Built with Java, it provides 800 plugins to support building an= d testing virtually any project."
Jenkins is a free open-source continuous build software package. It is m= anaged by the Jenkins CI community. It is well suited for Java based projec= ts, and some of the more notable features include:
Download and install Jenkins native package from http://jenkins-ci.org/= . Jenkins can also be deployed as a .war file in containers such as Tom= cat, but the configuration would be identical.
For the purpose of this tutorial we will use the native Jenkins stand-al= one installer.
You should now be able to access Jenkins at http://localhost:8080<=
/code>. This tutorial is based on a native Windows service installation, bu=
t it should be similar on other OSes as well.
As Jenkins and Servoy are both Java driven applications, they share some= Java technologies, and by default, share port configurations as well. If y= ou plan to run Jenkins and Servoy Application Server on the same machine, p= ort changes will need to be made one application or the other in order for = the applications to work properly.
Only one or the other needs to be modified, not both.
Changing ports for a Servoy Application Server installation is detailed = here.
To change port configurations for Jenkins instead, modify the jenk=
ins.xml
file found in the Jenkins main directory. See the section be=
low:
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=3Dhudson.lifecycle.W= indowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=3D8080</argu= ments>=20
Note that '--httpPort=3D8080' is in conflict with Servoy Application Ser=
ver default port. Change this port to any other available port on the machi=
ne (for example 8085) then restart the Jenkins service. The new URL to acce=
ss Jenkins will be http://localhost:8085
. (If you plan to inst=
all Jenkins as a .war inside another container such as tomcat, then that co=
ntainer's configuration determines the port and the URL will be something l=
ike http://localhost:8085/jenkins)
Jenkins is fully configurable from the browser. It has many useful plugi= ns. If you think you need something, look through the available plugins. Wh= at you need is probably already available.
In this tutorial we will use two plugins (to install them go - in the br= owser - to Manage Jenkins > Manage plugins):
Some plugins that we will use such as SVN plugin are pre-installed.
If you experience strange errors like '500 Internal Server Error' when c= onfiguring a Jenkins job to connect to a SVN location that requires authent= ication, check for updates to the Subversion Jenkins Plugin. Before plugin = version 2.0 there were problems connecting to some SVN servers (not all) du= e to an old SVNKit version used by this plugin.
At each SVN location defined in a job you will be able to choose a separ= ate 'Credential'. Those credentials can be managed from Manage Jenk= ins > Manage Credentials.
Now you should be the only one that can access the Jenkins server using = your google credentials.
You can add any other people and configure their rights as needed now.= p>
Note: Jenkins access can be configured in other ways as well, if you don= 't have a google/other openID account or you just want to use something els= e (LDAP/custom users).
Here are some settings you should/could tweak in Manage Jen= kins > Configure System:
ant-contrib*.jar=
is located in the unzipped contents - including file name.In the SVN repository we will have Servoy solutions that need to be auto= matically tested using import-smart-client and a solution to be automatical= ly tested in mobile-test-client. The ANT scripts used by Jenkins to automat= ically export and test Servoy solutions will be in a separate project 'antR= unner' in the same SVN repository.
This is what will happen when a Servoy - Jenkins job (defined later in t= his chapter) runs:
First we have to set-up sample SVN contents. This can be done on any com= puter with access to the SVN server, not necessarily on the same computer a= s Jenkins.
Here is the sample Servoy workspace that we will use: SoftwareFactory_Jenkins_Workspace.z= ip.
Unzip. Start Servoy Developer and switch workspace to the unzip location= (File > Switch Workspace).
Go to File > Import > Ge= neral > 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 fr= om developer.
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 m=
ake a SVN test server with SVN server software such as VisualSVN). I added =
it to something like http://{myHost}:{svnServerPort}/svn/jenkinsSolut=
ions/trunk/{projectName}
. For the first project you will have to cho=
ose 'create repository (connection) > http://{myHost}:{svnServerPo=
rt}/svn/jenkinsSolutions
and directory 'trunk/demo_ipAddressValidato=
r'. For the rest you will choose an existing SVN repository (the connection=
you just created).
After all projects are shared, select all from Navigator view, r= ight click > Team > Synchronize. In the Synchronize view select all and righ= t click > Commit.
We need an installation of Servoy Developer on the machine running Jenki= ns for exporting test solutions and running tests.
Download and install Servoy Developer. It's best to use a clean installa= tion (no extra eclipse plugins) to avoid potential problems generated by ot= her 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 re= source - in the headless solution export environment).
In case of Servoy 7.x: if for some reason you intend to custom-sign any = jars in that Servoy installation you must sign all the jars from both appli= cation server (relevant here is application_server/lib/j2db.jar) a= nd developer, as well as jars contained in developer/plugins/com.servoy= .eclipse.jsunit_*.jar (relevant here is j2db_test.jar). If th= ese jars are not identically signed then you will get an IllegalStateExcept= ion when trying to start the (smart) unit test client. But normally you wou= ld use just a clean install without custom-signing any jars.
Your Jenkins server should be able to access the SVN server you just com= mitted to - in case you didn't use the same computer. Navigate to the Jenki= ns server page in your browser.
Click on New Item > Build a free-style softw= are project, and set the Job name to 'smart_client_tests' ('_' is = used to avoid problems with spaces in paths where used as command line argu= ments - extra care is needed otherwise).
Under 'Advanced Project Options' click the button then in 'Display Name'= type Smart Client Tests.
Under 'Source Code Management' select Subversion. We will add the projec= ts needed for smart client tests one by one:
http://{myHost}:{svnServerPort}/svn/jenk=
insSolutions/trunk/solution1
. When you tab out of the field, if your=
SVN repository requires authentication - and you didn't already provide it=
, you will get a red error message 'Unable to access ... '. Click on the Note: you can also checkout the whole branch at once if all your project= s are needed for smart-client tests. Then you will have to leave the '.' in= 'Local module directory (optional)'.
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 tri= gger the build. If you want a check every minute use * * * * *.
Under 'Build Environment' check 'Abort the build if it's stuck', then se= lect 'Absolute' - 7 minutes. This will make sure that the build ends with f= ailure after 7 minutes if something gets stuck. This is optional and of cou= rse you need to tweak this depending on how long your tests usually take. T= his option is contributed to Jenkins by the 'build timeout plugin'.
Under 'Build' click on Add build step. Choose I= nvoke Ant. Select the version you configured to auto-install at 'O= ther things to configure' above. Click on Advanced. I= n 'Targets' type 'main_smart'. In 'Build file' type 'antRunner/jenkins_buil= d.xml'. In 'Properties', expand the field (arrow down button) then type:
work.servoy.i= nstall.dir =3D [path_to_your_separate_Servoy_developer_installation] smart_test_solutions =3D solution1,solution2 WORKSPACE =3D ${WORKSPACE} ANT_CONTRIB_JAR =3D ${ANT_CONTRIB_JAR}=20
If you are on windows use '/' or '\\' instead of '\' in that path. For e=
xample work.servoy.install.dir=3Df:/ServoyInstalls/Servoy_7.3
.=
Under 'Post-build Actions':
antR=
unner/jsunit_results/junit-noframes.html
, antRunner/jsunit_res=
ults/smart_import_test_client_log.txt
, antRunner/jsunit_result=
s/workspace_exporter_app_server_log.txt
, antRunner/jsunit_resu=
lts/workspace_exporter_workspace_log.txt
antRunner/jsunit_results/TESTS-TestSuites.xml
Click on Save and go back to Jenkins dashboard. The new= job you just created 'Smart Client Tests' should automatically start in un= der 3 minute (or you can start it manually using the play = icon next to it). It should pass.
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/...).
I also like to have 'AUTO REFRESH' enabled as well (a link in Jenkins da= shboard) - just to make sure the page is showing the latest status of Jenki= ns.
After a build finishes you should have 4 files in your build/Statu=
s/Build Artifacts
- one showing the test results and 3 Servoy log fi=
les showing what happened during export/import/test.
For mobile testing we will need Chrome browser installed (other browsers= , even mobile device simulations/emulations can be used, check the help pag= e of Servoy mobile test runner for details), a copy of SeleniumServer jar d= ownloaded (http://docs.seleniumhq.org/download/) and a copy of Chrome selen= ium driver downloaded/extracted (http://code.google.com/p/chromedriver/down= loads/list). The mobile test solution will automatically be deployed in Ser= voy 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 mo= bile 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.
Click on New Item > Build a free-style softw= are project, and set the Job name to 'mobile_client_tests'.
Under 'Advanced Project Options' click the button then in 'Display Name'= type 'Mobile Client Tests'.
Under 'Source Code Management' select Subversion. We will add the projec= ts needed for mobile client tests one by one:
http://{myHost}:{svnServerPort}/svn/jenk=
insSolutions/trunk/demo_ipAddressValidatorTester
. When you tab out o=
f the field, if your SVN repository requires authentication - and you didn'=
t already provide it, you will get a red error message 'Unable to access ..=
. '. Click on the "enter credential" link and add the SVN credentials that =
this test server is meant to useUnder '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 tri= gger the build. If you want a check every minute use * * * * *.
Under 'Build Environment' check 'Abort the build if it's stuck', then se= lect 'Absolute' - 10 minutes. This will make sure that the build ends with = failure after 10 minutes if something gets stuck. This is optional and of c= ourse you need to tweak this depending on how long your tests usually take.= This option is contributed to Jenkins by the 'build timeout plugin'.
Under 'Build' click on 'Add build step'. Choose 'Invoke Ant'. Select the= version you configured to auto-install at 'Other things to configure' abov= e. Click on 'Advanced'. In 'Targets' type 'main_mobile'. In 'Build file' ty= pe 'antRunner/jenkins_build.xml'. In 'Properties', expand the field (arrow = down button) then type:
If you are on windows use '/' or '\\' instead of '\' in that path.
work.servoy.i= nstall.dir =3D [path_to_your_separate_Servoy_developer_installation] deploy.servoy.install.dir =3D [path_to_your_deployment_Servoy_developer_ins= tallation] webdriver.chrome.driver =3D [path_to_chromedriver.exe_that_was_downloaded= _above] selenium.server.jar =3D [path_to_downloaded_selenium_server_jar] mobile_test_solutions =3D demo_ipAddressValidatorTester mobile_service_solutions =3D demo_ipAddressValidatorTester_service mobile_to_deploy =3D demo_ipAddressValidator mobile_to_deploy_services =3D demo_ipAddressValidator_service WORKSPACE =3D ${WORKSPACE} ANT_CONTRIB_JAR =3D ${ANT_CONTRIB_JAR}=20
For example:
work.servoy.i= nstall.dir =3D f:/ServoyInstalls/Servoy_7.3 deploy.servoy.install.dir =3D f:/ServoyInstalls/Servoy_7.3_deployment webdriver.chrome.driver =3D f:/Selenium/Drivers/Chrome/chromedriver.exe selenium.server.jar =3D f:/Selenium/ServerJar/selenium-server-standal= one-2.39.0.jar (...)=20
The deployment installation of Servoy can be the one that 'Install/Start= Servoy Server Importer' step will use.
Under 'Post-build Actions':
antR=
unner/jsunit_results/junit-noframes.html
, antRunner/jsunit_res=
ults/smart_import_test_client_log.txt
, antRunner/jsunit_result=
s/workspace_exporter_app_server_log.txt
, antRunner/jsunit_resu=
lts/workspace_exporter_workspace_log.txt
antRunner/jsunit_results/TESTS-TestSuites.xml
Click on Save and go back to Jenkins dashboard. The new= job should automatically start in under 3 minute (or you can start it manu= ally using the play icon next to it). It should export/run= tests in chrome/export normal solution/copy it to deployment Servoy instal= lation - with 2 test failures. To make the tests pass fix the regular expre= ssion 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/Buil= d Artifacts - one showing the test results and 3 Servoy log files showing w= hat happened while exporting/testing.
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 solu= tions. Here is how you can do that.
All the steps for creating jobs for your own solutions are almost identi= cal to the sample jobs (see 'Configure Smart Client Jenkins job' and 'Confi= gure Mobile Client Jenkins job' above). What you should do differently:
in case of Smart Client job - replace sample tests root solution nam= es below with your own; comma separated list:
smart_test_so= lutions =3D solution1,solution2=20
in case of Mobile Client job - replace sample root solution names be= low with your own; comma separated lists:
mobile_test_s= olutions =3D demo_ipAddressValidatorTester mobile_service_solutions =3D demo_ipAddressValidatorTester_service mobile_to_deploy =3D demo_ipAddressValidator mobile_to_deploy_services =3D demo_ipAddressValidator_service=20
antRunner/servoy.properties
file as needed by y=
our solutions (define servers and other needed changes; the repository serv=
er can be a Hslq (in memory) server to always import clean or you can chang=
e it to a persistent server as well).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 solu= tions 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 i= n Build > Add build step >= ; Invoke Ant > Advanced >= Properties > expanded. Customiza= ble properties are listed in the first section of 'antRunner/export_and_tes= t.properties' and are explained in their comments preceding each one:
# -----------= ---------------------------------------------------------------------------= ---------- # Properties that you should set in Jenkins job configurations (ant advance= d 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 =3D [your_jenkins_dedicated_servoy_inst= allation_dir] work.servoy.install.url =3D http://localhost:8080 # Paths to other downloaded tools that we need webdriver.chrome.driver =3D [path_to_the_downloaded_selenium_ch= rome_driver_executable] selenium.server.jar =3D [path_to_downloaded_selenium_server= _jar] # Solutions to be exported and then tested; # multiple solutions can be specified via a comma separated list of solutio= n names smart_test_solutions =3D solution1,solution2 mobile_test_solutions =3D demo_ipAddressValidatorTester mobile_service_solutions =3D demo_ipAddressValidatorTester_servi= ce mobile_to_deploy =3D demo_ipAddressValidator mobile_to_deploy_services =3D demo_ipAddressValidator_service # If you are using a Servoy version >=3D 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 o= f some unneeded exporter # initialization time # work.servoy.install.7.3.or.higher =3D yep # 1 hour time-out; edit this as needed - depending on how long it usually t= akes for your solution tests to run (should probably be lower in most cases= ) test.timeout =3D 3600000 # Uncomment the following to send '-pl' argument to workspace solution expo= rters: alternate project locations; # solution and resources projects will be searched for in direct subfolders= of the given 'WORKSPACE'. # Example: if the workspace needs to contain projects from different git re= positories, those can be checked # out in '[WORKSPACE]/repo1', '[WORKSPACE]/repo2' and so on #alternate_project_locations.on=3Dyep # Uncomment the following line/set this if you want passed exports generate= d by previous build # to be deleted at the beginning of each build cycle #always_clean_passed_exports =3D yep # For Sauce Labs test cloud (testing mobile clients); also uncomment releva= nt lines in # "run_mobile_client_tests_if_exported_ok" target of jenkins_build.xml; oth= er changes might be needed as well, but this is the main idea #sauce.labs.user =3D [your Sauce Labs user here] #sauce.labs.token =3D [access token goes here] #sauce.labs.selenium.url =3D http://${sauce.labs.user}:${sauce.l= abs.token}@localhost:${SAUCE_ONDEMAND_PORT}/wd/hub # define a timeout for sauce labs to not require additional Selenium comman= ds 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 =3D 90 # If you want your mobile solutions deployed to a Servoy server after testi= ng 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 copie= d to deploy.webapps.dir location. #deploy.servoy.install.dir =3D [your_mobile_war_deployment_servoy_= installation] #deploy.webapps.dir =3D ${deploy.servoy.install.dir}/applic= ation_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 - env= ironment variables #WORKSPACE =3D [if_not_set_by_Jenkins_you_can_conf= igure_it_as_well] #ANT_CONTRIB_JAR =3D [if_not_set_in_Jenkins_config_as_en= vironment_variable_you_can_configure_it_as_well]=20
antRunner/export_and_test.xml
macrodefs 'export-solution' and 'expo=
rt-mobile-solution'. You can see a list of available command line arguments=
in a console window by executing {servoyInstall}/developer/exporter/=
export.bat -help
and {servoyInstall}/developer/exporter/m=
obile_export.bat -help
;antRunner/export_and_test.xml
macrodefs 'run-smart-client-te=
sts' and 'run-mobile-client-tests'. You can see a list of available argumen=
ts by commenting out the '<!--arg value=3D"-help" /-->
' =
lines in these marcrodefs and creating/executing an ant task that calls the=
m 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).