Sahi Pro - Integrate with Jenkins
Before integration, you will first need an ant target to run the suite file. Download jenkins-sample.xml and save it in Sahi's root folder.Let us assume that Jenkins is available in
C:\.jenkins\
To run this ant target from Jenkins, follow these steps.
- From the Jenkins dashboard, click on
New job
. - Enter job name as
SahiPro
(This will be the name of the job identified by Jenkins.) - Select
Build a free-style software project
. Click OK.
A folder by name “SahiPro” should be available inC:\.jenkins\jobs
- At this point, you should be directed to the Configure page. Click on
Add build step
. Selectinvoke Ant
- Type
-f jenkins-sample.xml ff
or-f jenkins-sample.xml sahitests
(sahitests target is configured to retry the failed scripts) - In
Post Build Actions
, checkPublish JUnit test result report
and add this in the textboxuserdata/temp/junit/reports/*.xml
- Click Save.
- On the left menu, click Build now. This will create a workspace for your project. NOTE: The build will fail, but that is fine.
- If Sahi Pro is installed in C:\SahiPro, navigate to that folder from the file explorer. Copy all the contents inside C:\SahiPro and paste it in
C:\.jenkins\jobs\SahiPro\workspace
. The workspace folder should look like C:\SahiPro - On the Jenkins dashboard, click
Build now
. - After the tests have run, the link
Latest Test Result
should be visible on the Project home page. Click on it to view results.
INFO
- This target runs a suite file called demo.suite available in SahiPro\userdata\scripts\demo. This uses http://sahi.co.in/demo/ as the start URL. Hence, there is a property called
urlbase
with the valuesahi.co.in
. This is the base url. - Jenkins tries to look for reports in the workspace root folder. Look at a target called
report-gen
in jenkins-sample.xml. Reports can be generated in any directory. Familiarity of ant’stask is required to achieve this. - While specifying the target in
Add build step
, it is possible to specify the path to ANY Ant build file.
Eg.ant -f C:\sahi_pro\demo.xml all
, will run the targetall
in demo.xml - A test can be configured to run from Jenkins without moving Sahi into the workspace. Familiarity of Jenkins and ant is necessary to achieve this.