SpringMVC + Groovy in Openshift - groovy

I have used this Gradle Openshift quickstart to use gradle with openshift, everything worked even with Jenkins!
But, I wanna use Groovy, so I added the follow code in my build.gradle to compile groovy scripts to .class
See
sourceSets{
main{
java{
srcDir "src/main/java"
}
resources{
srcDir "src/main/java"
}
groovy{
srcDir "src/main/java"
}
}
test.java.srcDir "src/test/java"
}
It works locally, I'm using Tomcat7, but when I deploy the jenkins build fails with the message
:compileJava
:compileGroovy FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileGroovy'.
> java.net.SocketException: Permission denied
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or -- debug option to get more log output.
So, the problem is about Permission denied when gradle try to execute compileGroovy task, I guess is something in the OpenShift OS but I don't know what's wrong, I have inserted the follow code in the files .openshift/build and .openshift/pre-build, see below
pre_build file
if [ ! -d $OPENSHIFT_DATA_DIR/gradle-1.6 ]
then
cd $OPENSHIFT_DATA_DIR
mkdir gradle
wget http://services.gradle.org/distributions/gradle-1.6-bin.zip
unzip gradle-1.6-bin.zip
rm -f gradle-1.6-bin.zip
fi
if [ ! -d $OPENSHIFT_DATA_DIR/groovy ]
then
cd $OPENSHIFT_DATA_DIR
mkdir groovy
wget http://dl.bintray.com/groovy/maven/groovy-binary-2.4.1.zip
unzip groovy-binary-2.4.1.zip
rm -f groovy-binary-2.4.1.zip
fi
build file
cd $OPENSHIFT_REPO_DIR
echo SETTING GRADLE HOME
export GRADLE_USER_HOME=$OPENSHIFT_DATA_DIR/gradle
export GRADLE_HOME=$OPENSHIFT_DATA_DIR/gradle-1.6
export PATH=$GRADLE_HOME/bin:$PATH
gradle build
export GROOVY_USER_HOME=$OPENSHIFT_DATA_DIR/groovy
export GROOVY_HOME=$OPENSHIFT_DATA_DIR/groovy
export PATH=$GRADLE_HOME/bin:$PATH
Well, I can't compile groovy files inside openshift even I have installed the groovy, how to make groovy works on Openshift?

java.net.SocketException: Permission deniedusually means that you are trying to setup a server socket or comparable on a port you don't have permission for. This could be the firewall blocking, or on Linux systems a too low port number reserved for privileged users like root. I think OpenShift uses port in the 15000+ range, so the firewall is the most likely problem.

Related

Create Build in Jenkins by using command line with ssh

I hope you're doing well,
I'm traying to automate a Jenkins process using a bash script in Linux, in which I need to create a build, then with created build I need to create a build using the option "Build with parameters" and use a specific build to create it.
First I'm creating the build with a similar command (it is corking fine it created the build successfully):
ssh -l MyUser -p JENK_PORT JENK_SERver build job-build -s –v
it creates the build number 10 then I need to use this build to create another one for the job job-deploy, something like:
ssh -l MyUser -p JENK_PORT JENK_SERver build job-deploy -p COPY_PROMOTION_LEVEL=1 -p BUILD_SELECTOR="\<SpecificBuildSelector plugin=\"copyartifact#1.37\"\> \<buildNumber\>10 \</buildNumber\>\</SpecificBuildSelector\>" -s -v
when I ran it, I'm getting this error:
ERROR: Too many arguments: plugin=copyartifact#1.37>
If I change the "space" for &nbsp/&#032 or adding a back slash between SpecificBuildSelector and plugin=copyartifact#1.37, I got this error:
ERROR: Unexpected exception occurred while performing build command.
com.thoughtworks.xstream.io.StreamException: : only whitespace
content allowed before start tag and not \ (position: START_DOCUMENT
seen ... #1:1)
Do you know how can I do it??, create the build for an specific build in the command line by passing the build parameters with -p option?
Thanks in advance.

unable to initialize tflint

I installed tflint on my mac and when I try to execute --init it is throwing 401 error.
Could you tell me if I need to export any env variables to fetch git repo.
tflint --init
Installing `azurerm` plugin...
Failed to install a plugin. An error occurred:
Error: Failed to fetch GitHub releases: GET https://api.github.com/repos/terraform-
linters/tflint-ruleset-azurerm/releases/tags/v0.14.0: 401 Bad credentials []
.tflint.hcl file
plugin "azurerm" {
enabled = true
version = "0.14.0"
source = "github.com/terraform-linters/tflint-ruleset-azurerm"
}
i searched tflint documentation but could not find anything.
thanks,
Santosh
tflint requires azurem plugin to be installed. For that download the azurem proper plugin binary here: https://github.com/terraform-linters/tflint-ruleset-azurerm/releases/tag/v0.16.0 (check the version that you need) , unzip it and then move it to your user's .tflint.d/plugins directory (create it if it doesn't exist)
mv ~/Downloads/tflint-ruleset-azurerm ~/.tflint.d/plugins/
I was recently was trying to use tflint behind a corporate firewall and was getting checksums errors. I was able to resolve it by:
Adding the following to my .zshrc file. Try open ~/.zshrc to open the file from the Mac terminal.
setup_local_tflint_plugin() {
for PLUGIN in ${PLUGINS[#]}; do
TFLINT_PLUGIN_NAME=${PLUGIN%|*}
TFLINT_PLUGIN_VERSION=${PLUGIN#*|}
TFLINT_PLUGIN_DIR=~/.tflint.d/plugins/terraform-linters/tflint-ruleset-${TFLINT_PLUGIN_NAME}/${TFLINT_PLUGIN_VERSION}
mkdir -p $TFLINT_PLUGIN_DIR
FILE=$TFLINT_PLUGIN_DIR/tflint-ruleset-${TFLINT_PLUGIN_NAME}
if [ ! -f "$FILE" ]; then
echo "Downloading version ${TFLINT_PLUGIN_VERSION} of the ${TFLINT_PLUGIN_NAME} plugin."
curl -L "https://github.com/terraform-linters/tflint-ruleset-${TFLINT_PLUGIN_NAME}/releases/download/v${TFLINT_PLUGIN_VERSION}/tflint-ruleset-${TFLINT_PLUGIN_NAME}_${PLATFORM_ARCHITECTURE}.zip" > ${TFLINT_PLUGIN_DIR}/provider.zip
yes yes | unzip "${TFLINT_PLUGIN_DIR}/provider.zip" -d ${TFLINT_PLUGIN_DIR} | rm ${TFLINT_PLUGIN_DIR}/provider.zip
fi
done
chmod -R +x ~/.tflint.d/plugins
}
# Valid values for PLATFORM_ARCHITECTURE are:
# 'darwin_amd64', 'darwin_arm64', 'linux_386', 'linux_amd64',
# 'linux_arm', 'linux_arm64', 'windows_386', 'windows_amd64'
PLATFORM_ARCHITECTURE="darwin_amd64"
PLUGINS=("azurerm|0.16.0" "aws|0.16.0")
setup_local_tflint_plugin
Opening up my code editor and navigating to my Terraform scripts.
Creating a .tflint.hcl configuration file in the same folder as my Terraform scripts (like below).
config {
module = true
force = false
disabled_by_default = false
plugin_dir = "~/.tflint.d/plugins/terraform-linters/tflint-ruleset-azurerm/0.16.0"
}
plugin "azurerm" {
enabled = true
}
Opening a new terminal window (plugins should start installing).
Running tflint . --config ./.tflint.hcl.
Note: This only works for one plugin at a time (e.g. azurerm, aws, etc.).
To install a new plugin or plugin version simply add more to the PLUGINS attribute in the .zshrc file. To select the plugin, update the .tflint.hcl files plugin_dir attribute to point to the right plugin and version.

Azure batch job start tasks failed

I'm using Azure batch python API. When I'm creating a new job, I see exit code 128 (image attached). How can I know what is the reason for that?
I'm creating a new job using this code :
def wrap_commands_in_shell(commands):
return "/bin/bash -c 'set -e; set -o pipefail; {}; wait'".format(';'.join(commands))
job_tasks = ['cd /mnt/batch/tasks/shared/ && git clone https://github.com/cryptobiu/OSPSI.git',
'cd /mnt/batch/tasks/shared/OSPSI && git checkout cloud',
'cd /mnt/batch/tasks/shared/OSPSI && cmake CMake',
'cd /mnt/batch/tasks/shared/OSPSI && mkdir -p assets'
]
job_creation_information = batch.models.JobAddParameter(job_id, batch.models.PoolInformation(pool_id=pool_id),
job_preparation_task=batch.models.JobPreparationTask(
command_line=wrap_commands_in_shell(
job_tasks),
run_elevated=True,
wait_for_success=True
)
)
To diagnose, you can look at the stderr.txt and stdout.txt for the Job Preparation task that has failed in the Azure Portal, using Azure Batch Explorer, or using an SDK via code. If you look at which node ran the job prep task, navigate to that node, then the job directory. Under the job directory, you should see a jobpreparation directory. In that directory will have the stderr.txt and stdout.txt.
With regard to the exit code, there are a few potential problems that could cause this:
Did you install git, cmake and any other dependencies as part of a start task?
I get a 404 when I try to navigate to: https://github.com/cryptobiu/OSPSI. Does this repo exist? If it's a private repository, are you providing the correct credentials?
A few notes about your job_tasks array:
You should not hardcode the paths /mnt/batch/tasks/shared. This path to the "shared" directory may not be the same between Linux distributions. You should use the environment variable $AZ_BATCH_NODE_SHARED_DIR instead. You can view a full list of Azure Batch pre-filled environment variables here.
You do not need to cd into the directory for each command, you only need to do it once. You can rewrite job_tasks as:
['cd $AZ_BATCH_NODE_SHARED_DIR',
'TODO: INSERT YOUR COMMANDS TO SETUP AUTH WITH GITHUB FOR PRIVATE REPO',
'git clone https://github.com/cryptobiu/OSPSI.git',
'cd OSPSI',
'cmake CMake',
'mkdir -p assets']

Selenium testing with Jenkins

I have been trying to start selenium tests with browsers, not headless. I have my code in SVN and this should be build by Jenkins. Jenkins is on Linux.
Has anyone ever tried that or do you know what steps I should take? I am going through tutorials available on the internet but none of them work for me.
My current error is:
java.io.IOException: Cannot run program "cmd" (in directory
"/var/lib/jenkins/jobs/Tests/workspace"): error=2, No such file or
directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at hudson.Proc$LocalProc.(Proc.java:240) at
hudson.Proc$LocalProc.(Proc.java:212) at
hudson.Launcher$LocalLauncher.launch(Launcher.java:815) at
hudson.Launcher$ProcStarter.start(Launcher.java:381) at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:95)
at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:64)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at
hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:205) at
hudson.model.Build$BuildExecution.doRun(Build.java:162) at
hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1720) at
hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at
hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410) Caused by:
java.io.IOException: error=2, No such file or directory at
java.lang.UNIXProcess.forkAndExec(Native Method) at
java.lang.UNIXProcess.(UNIXProcess.java:187) at
java.lang.ProcessImpl.start(ProcessImpl.java:130) at
java.lang.ProcessBuilder.start(ProcessBuilder.java:1028) ... 15 more
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
When built without error, the workspace was only updated:
Building in workspace /var/lib/jenkins/jobs/Tests/workspace
Updating http://XX.XX.XXX.XX/resp/extend/Tests/EO at revision '2016-07-04T14:34:05.110 +0200'
At revision 5536
No changes for http://XX.XX.XXX.XX/resp/extend/Tests/EO since the previous build
Finished: SUCCESS
If you need any further details, let me know ...
UPDATE:
[workspace] $ /bin/sh -xe /tmp/hudson8771943326851387647.sh
+ ./script.sh
/tmp/hudson8771943326851387647.sh: line 2: ./script.sh: Permission denied
Build step 'Execute shell' marked build as failure
Finished: FAILURE
I have changed the windows command to shell command. The shell command is:
./script.sh
I think that the script inside the file i wrong, but does the error I have now mean that the script is wrong or does it reflect to something else? I do not know hwy we have "permission denied" - I have all the right in jenkins.
And this is my script.sh file content:
#!/bin/bash
function run_test {
echo "=== run Selenium tests in Jenkins ==="
ssh root#$1 "/src/test/java/mainTest/MainOrderTest start"
}
fi
I have no knowledge on shell command and I have not found any command that would run this program.
You are trying to run windows batch scripts on Linux hence the error.
Two options :
1. Either convert your build scripts to shell and use "execute shell" to call your shell scripts in jenkins
2. Add a windows slave which will build your windows batch script

Jenkins job failed due to tests failed. Source code for tests include AWT GUI tests, how to use Xvfb plugin

Environment - Linux. << I log on to this machine as me (c123456) and then do "sudo su - jenkins"
Language - Java
Project Structure
src/java -- Java source code
test/java -- Junit Unit tests
src/java-test -- Integration tests
Build system - Gradle
build.gradle sourceSets definitions:
sourceSets {
main {
java {
srcDir 'src/java'
}
}
test {
java {
srcDir 'test/java'
}
}
integrationTest {
java {
srcDir 'src/java-test'
}
}
}
Lets say I successfully checked out source code for Project "ProjectABC" somewhere.
When I run "gradle clean build", everything runs fine on my local machine (Windows Win7 desktop)
using Cygwin session. Java compile and test run is successful.
When I run "gradle clean build" on a Linux terminal i.e. using a putty Session, it fails during the test task but Java compile part is successful.
When I run "gralde clean build -x test", it works (as we are excluding test task call).
Im getting the following error message when I use "gradle clean build" on a putty session:
:compileTestJava
Download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/junit/junit/4.11/junit-4.11.pom
Download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.pom
Download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/junit/junit/4.11/junit-4.11.jar
Download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
/production/jenkinsAKS/jobs/ProjectABCUtilities/workspace/test/java/com/tr/ids/util/test/tree/TestMultiParentTree.java:5: warning: unmappable character for encoding UTF8
* Copyright � 2005 Thomson MICROMEDEX. All Rights Reserved.
^
/production/jenkinsAKS/jobs/ProjectABCUtilities/workspace/test/java/com/tr/ids/util/test/tree/TestSingleParentTree.java:5: warning: unmappable character for encoding UTF8
* Copyright � 2005 Thomson MICROMEDEX. All Rights Reserved.
^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:processTestResources UP-TO-DATE
:testClasses
:test
Download http://artifactory_server2:8081/artifactory/jcenter-cache/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002.pom
Download http://artifactory_server2:8081/artifactory/jcenter-cache/org/jacoco/org.jacoco.build/0.6.2.201302030002/org.jacoco.build-0.6.2.201302030002.pom
Download http://artifactory_server2:8081/artifactory/jcenter-cache/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002.jar
Xlib: connection to "localhost:12.0" refused by server
Xlib: PuTTY X11 proxy: wrong authorisation protocol attempted
com.tr.ids.util.test.chart.TestChartUtilities > getPieChart FAILED
java.lang.InternalError at TestChartUtilities.java:89
com.tr.ids.util.test.chart.TestChartUtilities > getLegend FAILED
java.lang.NoClassDefFoundError at TestChartUtilities.java:103
com.tr.ids.util.test.chart.TestChartUtilities > useString FAILED
java.lang.NoClassDefFoundError at TestChartUtilities.java:143
140 tests completed, 3 failed
:test FAILED
FAILURE: Build failed with an exception.
As you see above, ":test" task is called at the very last. Only this project ProjectABC has this test case where the test source code has a .java file which includes the following code:
i.e. under /test/java/com/tr/ids/util/test/...*.java, *.html
The file which is giving problem is: TestChartUtilities.java
Test source code - Java file Code snapshot is:.
See lines/line# 89, 103 and 143 where line contains: "result = ChartUtil." keyword
package com.tr.ids.util.test.chart;
import java.awt.Color;
import java.io.UnsupportedEncodingException;
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import com.tr.ids.util.api.chart.ChartData;
import com.tr.ids.util.api.chart.ChartUtil;
import com.tr.ids.util.test.BaseTestCase;
..
....
......more code here ...
....
...
// #############################################################################
// Test.
// #############################################################################
/**
* Test simple string with ampersand character.
*/
public void getPieChart() {
ChartData chartData = new ChartData();
try {
chartData.addChartItem(25, new Color(255,255,0));
chartData.addChartItem(25, new Color(255,0,255));
chartData.addChartItem(25, new Color(0,255,255));
}
catch (Exception e) {
fail("Exception occured while building the ChartData object (probably 0 amount)");
}
byte[] result = null;
try {
result = ChartUtil.drawPieChart(chartData, 300); // <--- line# 89 which is failing.
} catch (Exception e) {
fail("Exception occured trying to drawPieChart.");
}
assertNotNull("No pie chart returned", result);
}
..
....
......more code here ...
....
...
/**
* Test simple string with apostrophe and quote characters.
*/
public void getLegend() {
byte[] result = null;
try {
result = ChartUtil.drawLegend("ff0000", 40); // <--- line# 103
} catch (Exception e) {
fail("Exception occured while drawing a legend box");
}
assertNotNull("No legend image returned", result);
}
/**
* Test simple string with less than and greater than characters.
*/
public void useString() {
ChartData chartData = new ChartData();
try {
chartData.addChartItem(25, new Color(255,255,0));
chartData.addChartItem(25, new Color(255,0,255));
chartData.addChartItem(25, new Color(0,255,255));
}
catch (Exception e) {
fail("Exception occured while building the ChartData object (probably 0 amount)");
}
String graphDesc = null;
try {
graphDesc = chartData.generateStringRepresentaion(false);
} catch (UnsupportedEncodingException e1) {
fail("Exception occured while building the ChartData object (probably 0 amount)");
}
ChartData chartData2 = new ChartData();
try {
chartData2.loadFromString(graphDesc);
} catch (NumberFormatException e) {
fail("NumberFormatException thrown loading from string");
} catch (Exception e) {
e.printStackTrace();
fail("Exception thrown");
}
byte[] result = null;
try {
result = ChartUtil.drawPieChart(chartData2, 300); // <--- line# 143
} catch (Exception e) {
fail("Exception occured trying to drawPieChart.");
}
assertNotNull("No pie chart returned for chart loaded from string", result);
}
Now, As I mentioned earlier, in Cygwin (Windows local machine), everything works as I may have all the Graphical/AWT settings/tools available on my local machine via Cygwin.
Now, what could I be missing???
As I also getting the same error (when running via Putty session) in Jenkins job as well, I thought installing / using Jenkins "Xvfb Plugin" would help as it says:
Lets you control Xvfb virtual frame buffer X11 server with each build. It starts Xvfb before the build starts, and stops it with the build. This is very useful if your build requires X11 access, for instance runs tests that require GUI.
I configured this plugin according to the instructions: https://wiki.jenkins-ci.org/display/JENKINS/Xvfb+Plugin
but, it's still giving me an error.
Jenkins logs (When I'm not using Jenkins Xvfb plugin) is showing the same error like I'm getting in a Putty session.
Similarly, when "gradle clean build -x test" is called, Jenkins job is successful but I have to run "gradle clean build" (which fails).
Now, When enabling Jenkins "Xvfb" plugin in Jenkins Global configuration (under Manager Jenkins > Configure System) and at Job's configuration level, I'm getting the following error in Jenkins log during the execution:
..
....
15:30:11 Xvfb starting$ Xvfb :2 -screen 0 1024x768x24 -fbdir /production/jenkinsAKS/2013-08-23_15-30-072456509552045645846xvfb
..
...
...
:compileTestJava
Download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/junit/junit/4.11/junit-4.11.pom
Download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.pom
Download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/junit/junit/4.11/junit-4.11.jar
Download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
/production/jenkinsAKS/jobs/ProjectABCUtilities/workspace/test/java/com/tr/ids/util/test/tree/TestMultiParentTree.java:5: warning: unmappable character for encoding UTF8
* Copyright � 2005 Thomson MICROMEDEX. All Rights Reserved.
^
/production/jenkinsAKS/jobs/ProjectABCUtilities/workspace/test/java/com/tr/ids/util/test/tree/TestSingleParentTree.java:5: warning: unmappable character for encoding UTF8
* Copyright � 2005 Thomson MICROMEDEX. All Rights Reserved.
^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:processTestResources UP-TO-DATE
:testClasses
:test
Download http://artifactory_server2:8081/artifactory/jcenter-cache/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002.pom
Download http://artifactory_server2:8081/artifactory/jcenter-cache/org/jacoco/org.jacoco.build/0.6.2.201302030002/org.jacoco.build-0.6.2.201302030002.pom
Download http://artifactory_server2:8081/artifactory/jcenter-cache/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002.jar
15:30:51 Xlib: connection to "localhost:16.0" refused by server
15:30:51 Xlib: PuTTY X11 proxy: wrong authorisation protocol attempted
15:30:52
com.tr.ids.util.test.chart.TestChartUtilities > getPieChart FAILED
java.lang.InternalError at TestChartUtilities.java:89
com.tr.ids.util.test.chart.TestChartUtilities > getLegend FAILED
java.lang.NoClassDefFoundError at TestChartUtilities.java:103
com.tr.ids.util.test.chart.TestChartUtilities > useString FAILED
java.lang.NoClassDefFoundError at TestChartUtilities.java:143
140 tests completed, 3 failed
:test FAILED
FAILURE: Build failed with an exception.
As you notice, this time I'm getting lines.
15:30:51 Xlib: connection to "localhost:16.0" refused by server
15:30:51 Xlib: PuTTY X11 proxy: wrong authorisation protocol attempted
15:30:52
When at Job level configuration for Xvfb's Advance configurtion, I mentioned value in the box for "Xvfb specific Display name" as 13 or 16 (as per the plugin), I see the same errors for tests part (as I got earlier), but X11 related error this time, comes as:
15:31:42 Xvfb starting$ Xvfb :16 -screen 0 1024x768x24 -fbdir /production/jenkinsAKS/2013-08-23_15-31-388454769980302593302xvfb
15:31:42 _XSERVTransSocketINETCreateListener: ...SocketCreateListener() failed
15:31:42 _XSERVTransMakeAllCOTSServerListeners: server already running
15:31:42
15:31:42 Fatal server error:
15:31:42 Cannot establish any listening sockets - Make sure an X server isn't already running
15:31:42 unlink: No such file or directory
15:31:42 unlink failed, errno 2
15:31:44 ERROR: Xvfb failed to start, consult the lines above for errors
ps -eAf|grep -i xvfb - doesn't show anything running on the Linux server.
When Jenkins job runs using Xvfb plugin, it initiates the call to start / stop the X Display during it's execution automatically (as per Xvfb plugin's features on Jenkins Xvfb help page).
I also found that X11 forwarding is enabled on Linux machine:
# grep X11F /etc/ssh/sshd_config
X11Forwarding yes
#
One thing I notice is, the user which I use to run Jenkins is: "jenkins" and once I log to the Linux machine as me (c123456 id) and then do "sudo su - jenkins", then, there's is NO .XAuthority file.
Doing: ... does show it exists:
ls -ltra ~c123456
-rw------- 1 c123456 devgroup 406 Aug 23 13:07 .Xauthority
But, the same doesn't exist for user jenkins i.e. ls -ltra ~jenkins (doesn't have any .XAuthority file).
Linux $DISPLAY variable is set but "xclock" doesn't work. I have it X11 setting enabled/checked for X11 forwarding (at client side i.e. on my Windows local machine putty setting for target Linux machine session).
[c1234563#devserver1 ~]$ echo $DISPLAY
localhost:15.0
[c1234563#devserver1 ~]$ xclock
X connection to localhost:15.0 broken (explicit kill or server shutdown).
[c1234563#devserver1 ~]$
I tried this link but still not able to resolve the issue, following what it says to resolve it.
http://froebe.net/blog/2008/11/14/getting-xlib-putty-x11-proxy-wrong-authentication-protocol-attempted-i-have-the-answer/
What could I be missing at this point which can help me:
1) to resolve the tests fail issue using Putty session or through Jenkins job way.
2) I'm wondering if Xvfb plugin is doing the X Display using memory frame buffers, then I should not install any X Display server/client on my local Windows machine / target Linux machine like XMing, XVnc/TightVnc etc.
A Putty session and a jenkins job will probably have 2 slightly different run environments. Because of the way it was configured, Putty wants to use your remote X server, while jenkins is probably headless and requires xfvb or similar environment.
For your tentative trough Putty to work, you might want to add "ForwardX11Trusted yes" in /etc/ssh/sshd_config on your server, or use xauth. But this will make your GUI appear on your Windows client. Probably not what you really want: you don't want to have to export your display to a remote server to run your automated build.
To fix jenkins, I am not 100% sure yet. The Xfvb plugin fails because you already have a server running on the port it tries to use. You may want to check with netstat -ln and search for ports (potentially around 6000+). Let's start with that.
This is an odd answer, but I did the following to resolve the issue. I know I'll need Xvfb plugin sooner or later but..
Removed my workspace/jenkins job -or renamed the jenkins job. Take backup if you delete.
On putty, gradle clean build and gradle clean build jacocoTestReport worked.
In Jenkins it still failed.
a. Removed Jenkins Xvfb plugin
b. Restarted Jenkins instance
Problem resolved.
As I said, for GUI tests, I'd need Xvfb but the issue I was getting is not coming now after doing the above steps.
Final Update: Solution is to remove Jenkins job's workspace folder's data.

Resources