Search code examples
jenkinsgetgauge

How to integrate Gauge with Jenkins


I am somewhat familiar with Gauge testing tool and am now working on executing it via Jenkins.

First: i set gauge --version in the "Execute Windows Batch Command" field. This was the output:

Started by user anonymous
Building in workspace C:\jenkins\workspace\Run_Gauge_Test
[Run_Gauge_Test] $ cmd /c call C:\WINDOWS\TEMP\hudson8329964667758110371.bat

C:\jenkins\workspace\Run_Gauge_Test>gauge --version 
Gauge version: 0.6.2

Plugins
-------
No plugins found
Plugins can be installed with `gauge --install {plugin-name}`

C:\jenkins\workspace\Run_Gauge_Test>exit 0 
Finished: SUCCESS

Compare this to the output I get if I run Gauge directly in command line:

C:\jenkins\workspace\Run_Gauge_Test>gauge --version
Gauge version: 0.6.2

Plugins
-------
html-report (2.1.1)
java (0.5.1)
xml-report (0.1.3)

So i put the same command in a batch file and ran it only to get the "no plugins found" message again. As a last option I ticked the Use custom workspaceand set my directory to a folder where I usually run gauge tests from command line but still it is "no plugins found"

Then i tried running it as a shell command. Output:

Started by user anonymous
Building in workspace C:\jenkins\workspace\Run_Gauge_Test
[Run_Gauge_Test] $ sh -xe C:\WINDOWS\TEMP\hudson211231385407124893.sh
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: Cannot run program "sh" (in directory "C:\jenkins\workspace\Run_Gauge_Test"): CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    (truncated)
    at hudson.model.Executor.run(Executor.java:404)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    ... 16 more
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Of course, I am going to actually run the gauge tests(and it doesnt work) rather than just get the version; but I thought it would be simpler to troubleshoot why it doesnt get plugin details correctly. Any clues?


Solution

  • Gauge plugins should be installed via user/admin account with which the Jenkins agent executes commands. Have a look at following doc for more on integrating with GoCD and few other CI tools. https://docs.gauge.org/latest/howto/index.html#tutorials

    Long answer:

    Currently, Gauge executable is installed at system level. Whereas Gauge plugins(language runners, reporting plugins etc) are installed at a user level. So if you install plugins as one user manually and on CI if task is run against different user, gauge will not be able to find plugins.

    To fix this, you should run plugin install commands from the account with which CI runs. Or as Srikanth's comment says, you can have gauge --install-all task in pipeline. This installs all required plugins on the fly.