1
votes

I am not having any issues when running in Eclipse, but when I attempt to run an ANT build within Jenkins I get the following:

java.lang.IllegalStateException: The driver executable does not exist: C:\Program Files (x86)\Jenkins\jobs\Update InforTAP Build\workspace\lib\geckodriver0-19.exe

Image capture of file info The exe exists in that exact directory and the permissions have been set to 777. Test that run within a 3rd party server are working fine. That seems to point to this being the only issue in the way of running locally using Jenkins.

Here is the data ouput: (Notice that I have removed "ANT_BUILDS")

before :C:\Program Files (x86)\Jenkins\jobs\Update InforTAP Build\workspace\ANT_BUILDS browser

location: lib\geckodriver0-19.exe

after :C:\Program Files (x86)\Jenkins\jobs\Update InforTAP Build\workspace\lib\geckodriver0-19.exe

The lib directory is here: C:\Program Files (x86)\Jenkins\jobs\Update InforTAP Build\workspace\lib\

The ANT build file is located here: C:\Program Files (x86)\Jenkins\jobs\Update InforTAP Build\workspace\ANT_BUILDS\

    final FirefoxOptions firefoxOptions = new FirefoxOptions();

                ensureOneDriverInstance(Browser.GEKODRIVER_EXE_NAME);

                System.setProperty("webdriver.gecko.driver", Browser.getDriverExeLocation(Browser.FIREFOX));
                System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true");
                System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "/dev/null");

                firefoxOptions.addPreference("browser.popups.showPopupBlocker", false);
                firefoxOptions.addPreference("security.sandbox.content.level", 5);

                driver = new FirefoxDriver(firefoxOptions);

public static String getDriverExeLocation(final Browser browserType) {
        String currentWorkingDirectory = null;
        String browserLocation = null;

    public static final String GEKODRIVER_EXE_NAME = "geckodriver0-19.exe";
    public static final String GEKODRIVER_EXE_LOCATION = "lib\\\\" + GEKODRIVER_EXE_NAME;

browserLocation = GEKODRIVER_EXE_LOCATION;
currentWorkingDirectory = UtilsFile.getCurrentDirectory();
        System.out.println("before :" + currentWorkingDirectory);
        System.out.println("browser location: " + browserLocation);
        if ((currentWorkingDirectory != null) && currentWorkingDirectory.contains("ANT_BUILDS")) {
            if (browserLocation != null) {
                System.setProperty("user.dir", currentWorkingDirectory.replaceAll("ANT_BUILDS", ""));
                browserLocation = currentWorkingDirectory.replaceAll("ANT_BUILDS", browserLocation);
            }
        }
        System.out.println("after :" + browserLocation);
        return browserLocation;
}

Here is the ANT BUILD file

<property name="RELEASE_ROOT" value="workspace/" />
<property name="BASE_ROOT" value="${basedir}/workspace/" />
<property name="SRC" value="${RELEASE_ROOT}/src" /> <!-- Change it to your source folder -->
<property name="LIB" value="${RELEASE_ROOT}/lib" /> <!-- Change it to your lib folder --> 
<property name="SELENIUM.LIB" value="${RELEASE_ROOT}" /> <!-- Change it to your lib folder --> 
<property name="BIN" value="${RELEASE_ROOT}/bin1" /> <!-- Change it to your binary folder where you need to gerate the compiled binary file -->
<property name="REPORT" value="${RELEASE_ROOT}/reports/ANT" /> <!-- Change it to your output report folder -->

<property environment="env" />
    <property name="CATALINA_HOME.LIB" location="${env.CATALINA_HOME}/lib"/>
    <property name="CATALINA_HOME.BIN" location="${env.CATALINA_HOME}/bin"/>

<import file="${CATALINA_HOME.BIN}/catalina-tasks.xml"/>


<fileset dir="${SELENIUM.LIB}" id="http.jars">
        <include name="lib/httpclient*.jar" />
        <include name="lib/httpcore*.jar" />
    </fileset>

<fileset dir="${CATALINA_HOME.LIB}" id="CATALINA_HOME.jars">
    <include name="servlet-api.jar" />
    <include name="**/*.jar" />
</fileset>

<fileset dir="${SELENIUM.LIB}" id="SELENIUM.jars">
    <include name="lib/*.jar" />
</fileset>

<path id="test.classpath"> <!-- Creating a classpath for use while compiling -->
    <fileset refid="http.jars" />
    <fileset refid="CATALINA_HOME.jars" />
    <fileset refid="SELENIUM.jars" />
    <pathelement location="${BIN}" />
</path>

<target name="init"> <!-- Initialization target which deletes and recreates the binary folder.-->
    <delete dir="${BIN}" />
    <mkdir dir="${BIN}" />
</target>

<target name="compile" depends="init"> <!-- Target for compiling the source folder  -->
        <javac  includeantruntime="false" source="1.8" srcdir="${SRC}" fork="true" destdir="${BIN}" encoding="UTF-8" > 
            <classpath>
                <fileset refid="http.jars" />
                <fileset refid="CATALINA_HOME.jars" />
                <fileset refid="SELENIUM.jars" />
                <pathelement location="${BIN}" />
            </classpath>
        </javac>
    </target>


<target name="run-regression"> <!-- Target to run test in batches. -->
    <delete dir="${REPORT}" />
    <mkdir dir="${REPORT}" />
    <mkdir dir="${REPORT}/xml" />                   
<junit printsummary="yes" haltonfailure="no">
<jvmarg value="-Duser.dir=${BASE_ROOT}"/>   <!-- has to be absolute path  echo the path to see what we have so far-->
        <classpath>
            <pathelement path="${BIN}" />
                <fileset refid="CATALINA_HOME.jars" />
                <fileset refid="SELENIUM.jars" />
        </classpath>
        <test name="com.infor.infortap.tomcatpa.testsuite.TestSuiteRegressionInternalAdmin" haltonfailure="no" todir="${REPORT}/xml" outfile="TEST-result"> 
                <formatter type="xml" />
        </test>

    </junit>
        <junitreport todir="${REPORT}">
            <fileset dir="${REPORT}/xml">
                <include name="TEST*.xml" />
            </fileset>
            <report format="frames" styledir="${RELEASE_ROOT}/reports/report-formats" todir="${REPORT}/html" />
        </junitreport>

    </target>

<target name="compile-and-run-regression-internal-admin" depends="compile, run-regression"/>

1
It has to be some type of permissions issue. I stopped the Jenkins Windows service and started using the java -jar jenkins.war command and everything works. This is not really a long term solution as we will have to manually start the Jenkins service if the VM is rebooted or someone accidentally closes the window.Mike Cook
I wonder if this would resolve my issue Move Jenkins Intall DirectoryMike Cook

1 Answers

0
votes

The answer was to create a Jenkins Home directory instead of trying to use the default setup. Create a Jenkins Home Directory

I am also having the windows service log in using a userID instead of selecting the first option to allow the windows service use the current session.