18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Passing values from Jenkins to Sahi Scripts

SreekanthSreekanth Members
edited May 2014 in Sahi Pro
Hello All,

In a scenario, we are required to pass ID of Jenkins user to SAHI. is there any way on how this can be achieved.
I can do it by writing the value to a text file and then taking it from there. but it gives me a problem that there could be multiple jenkins users executing the job at a time. there is a possibility of the value in text to get replaced by another userid. Because of which, the value has to be passed using a variable.

I saw few threads in which its said that this can be achieved using -initJS. Tried using the same but it didnot work.
Will be great help if anyone could give more details on the configurations needed to make it work or may be even another way of achieving this.

OS: windows.
SAHI: Sahi pro v5.1.2
browser: firefox.


Regards,
Sreekanth

Answers

  • globalwormingglobalworming Moderators
    When starting a suite you can pass the initJS like this:
    java -cp $SAHI_HOME/lib/ant-sahi.jar net.sf.sahi.test.TestRunner \
      -test $SUITE \
      -browserType $BROWSER \
      -baseURL http://sahi.example.com/_s_/dyn/Driver_initialized \
      -host localhost \
      -port 9999 \
      -threads 1 \
      -useSingleSession false \
      -initJS " \
      \$jenkinsBuildIndex='$BUILD_NUMBER'; \
      \$jenkinsTimestamp='$BUILD_ID'; \
      \$jenkinsJobName='$JOB_NAME'; \
      \$jenkinsSlave='$NODE_NAME'; \
      " \
    
    // just access them in Sahi scritps like
    _alert($jenkinsTimestamp);
    
  • SreekanthSreekanth Members
    edited May 2014
    Thanks globalworming,

    Tried it but in sahi it said Variable not defined. This I tried in SAHI OS.

    In SAHI Pro, I got it working using:
    var $userJenkins = $suiteInfo["customField"];
    for this, I gave following in ant script.
    <customfield key="customField" value="${BUILD_USER_ID}"/>


Sign In or Register to comment.