I already managed to set up a Jenkins-Slave on a Windows 7(x64) machine. I'm also able to attach Jobs to the slave and they get succesfully executed. But all tasks seem to be running in headless mode!? We have some graphical Swing-Tests that are starting a Swing GUI and executing Macros on it. When executing the corresponding Maven-Command manualy on the slave-node
mvn -B -f C:\Jenkins\workspace\3-Test-Script-GUI-Test\pom.xml clean test
everything works fine, but when triggering this command via Jenkins the Swing-GUI doesn't open and the tests fail.
Are jenkins-jobs by default triggered in headless mode or is there any other configuration that could help me to resolve this problem?
The jenkins-slave.xml looks as follows:
<executable>javaw.exe</executable>
<arguments>-Xrs -jar "%BASE%\slave.jar" -tcp %BASE%\port.txt</arguments>
The manual tests may (appear to) work when run from an X11 session running on the host, as the X server functions as valid peer for AWT components. Some alternatives (VNC, Xvfb) for headless mode are mentioned here.
Related
I've been stuck two weeks trying to figure out how to run this at startup.
I use the following chain of commands on the terminal:
1. source ~/.bashrc
2. source ~/.tinyos.sh
3. java net.tinyos.tools.Listen -comm serial#/dev/ttyUSB0:telosb | python demo.py`
The third command uses java to listen to the serial port and pipes it to a python script which cleans, converts and uploads to mysql localhost.
This works fine on ssh terminal. But ive tried using nohup+update-rc.d, upstart, systemd, crontab to make it run on startup and it just wont work! When I reboot and check logs / database, its as if the command never happened. I need this to run like a daemon and continue running until shutdown.
Thanks a lot.
How are you trying to execute the program ? Are there are permission issues accessing / executing the script ?
Which version of debian are you running - look at upstart scripts if you are running Jesse+
I'd put those three lines in a bash script and use upstart scripts to trigger them on start. Another option is to use supervisord to make sure that your scripts run and restart if for any reason the program crashes.
I'm pretty new to setting up jenkins so please bear with me. I'm trying to remote execute a shell script that stops and starts up my stand alone Jetty deployment after Jenkins has finished building and deploying the files to this server.
http://imgur.com/PXGHqtl
(screenshot of the Post Build settings on Jenkins coz I'm not 10 rep yet...)
So the problem I'm having is that once the build reaches this stage and the Send Files over SSH plugin begins to execute the jetty.sh start script, I get a timeout error because the sh script seemingly doesn't return any completion acknowledgement (ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after 120,003 ms]). This causes the build to fail despite the jetty service starting up correctly.
I have tried playing around with the Advanced settings by enabling the "Exec in pty" but this causes the started up jetty service to be shut down again as soon as this step completes.
Does anyone have suggestions as to what else I could try? Is my approach correct or completely wrong?
Why I am getting the timeout error
There's a built in timeout in the advanced section of the Send Files over SSH plugin. By default it is set to time out at 120 seconds on inactivity on the SSH connection. In this instance I am running the Send Files over SSH post task with "Exec in Pty" option disabled. When this option is checked, the plugin will connect to the deployment server over a virtual SSH Terminal session and afterwards, it doesn't exit the session by itself so it simply waits for the timeout.
Why the jetty service starts up but shuts down immediately
With the "Exec in Pty" option enabled, a proper SSH Terminal session is used to connect to my deployment server. This ties any outputs and processes to the actual terminal session. When the Send Files over SSH plugin completes the jetty startup script execution, it exits by itself but in doing so, kills any process launched by the script.
Solution
After much digging around i found a solution to launch my script using a command: 'nohup ./jetty.sh start > /dev/null 2>&1 &' in place of my usual ./jetty.sh start command. There is a downside to this though. The output is not redirected to the terminal session so I won't know if my jetty service started up properly. But for now I'm satisfied with the solution so far since it's only going to deploy to my development environments.
Sources
Terminating SSH session executed by bash script
Jenkins Text-finder unable to success my Build
Jetty server stops running after closing terminal window
I have a batch file which start Tomcat as follows (when running it on Windows it works fine)
...
start C:\Users\root\tomcat\tomcat2\bin\startup.bat
The batch file is called from Jenkins as follows
I have this error in the Jenkins Consol at the end of the build
D:\jenkins\workspace\Start 3T2>start C:\Users\root\tomcat\tomcat2\bin\startup.bat
Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information
Finished: SUCCESS
When I check the task manager I see that the server is started but in background. I need actually to start Tomcat it in the Console.
This is what I did :
I added -Dhudson.util.ProcessTree.disable=true in jenkins-slave.xml
used to start jenkins slave service.
I added set BUILD_ID=dontkillme in startup.bat to stop Jenkins from
stopping the process in the end.
I think Tomcat start correctly in the end but not in Console. I'm running Windows 2012 server/Tomcat7/Jenkins 1.578.
Any idea on how to start Tomcat in a Console ?
AFAIK, if you're trying to start Tomcat console on a given machine which has Jenkins configured as service, it will not work. To make it work, you will have to connect to the given machine using JNLP. In case it's a standalone system and you want to open a Tomcat console using Jenkins, you will have to set up a Slave on the same machine and that too using JNLP (Launch slave agents via Java Web Start) in the Launch method section in Jenkins > Manage Jenkins > Manage Nodes > Slave Node's Configure page.
You can connect to the slave using any of the methods shown below. You will see the below option as soon as you configure the slave node and click Save. I ran the highlighted command from the Win command prompt. In my set up, i had configured Master and Slave on the same machine. I have Win 7 Professional, 64-bit laptop.
Once you run the command, you will see a small window that will pop-up and will display 'Connected' message as shown below:
At least for me, i checked that hudson.util.ProcessTree.disable=true & BUILD_ID parameters were not required. The only thing that i needed was to make sure that the following property is unset: HUDSON_SERVER_COOKIE
P.S.: You might have to make sure to start JNLP on reboot. A start-up script will do that. Also, ensure that your project/job is tied to the given slave which is running using JNLP mechanism.
i was going crazy with this , as shutdown.sh worked from Window-Master-Jenkin-->Linux-Slave-Jenkins, but startup.sh was not happening on my linux-slave-jenkins though startup.sh execution showed success message, as there were no logs anywhere, it was difficult to troubleshoot, not sure how and why setting up "export HUDSON_SERVER_COOKIE= " just before running startup.sh worked. Anyway Thanks a lot.
I am working with a large Java program that uses a command line shell to run integration tests. How do I attach eclipse to that process? Do I have to run the process and then attach it? It would be great to attach it to the shell process before I run it.
When you start your integration tests, add the following arguments to Java.
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
The suspend=y will pause startup until you attach with the debugger. In Eclipse, go to Run => Debug Configurations. Create a new "Remote Java Application" configuration and specify localhost as the host and 8000 as the port.
I have an Ant Task in the Jenkins Ant Execution Plugin, as a Post Build Step, to remotely run a shell script in one of our servers. The shell scripts starts a java process in the background. When I execute the shell script on the server directly it starts the java process in the back ground and comes out. When I run it from Jenkins via the sshexec task the shell script is run, but it never comes out and the Jenkins Build waits.
Later when I added the timeout attribute onto the sshexec it times out after the given number of milliseconds, but the Jenkins build is shown as failed. How do I make the sshexec task to come out cleanly from the shell script execution?
Here is my ssheexec task
<sshexec host="${deploy.host}" username="${deploy.username}" password="${deploy.password}" command=". /etc/profile; cd ${deploy.path}; sh start.sh i1" trust="true" timeout="10000" />
The start.sh file is as given:
nohup java -Xms512m -Xmx1024m -cp calculation.jar com.tes.StartCalculation $1 &
echo $! > calculation-$1-java.pid
It looks like, the ssh executed job is not fully daemonized. Starting with nohup is not sufficient in many cases.
See the discussion that related to it (in a different context)
The issue is that you are not closing your file descriptors when you
push something into the background. The & is fine when you are in a
shell, but is not enough when you want to disconnect and leave a
process running, you need the process to disconnect from the shell.
.... Fix to to correct the script.
If someone writes a naive service script that does not properly detach
from the terminal, I want to know the first time that that script is
used in a deployment - the SCM changes will enable the breaking change
to be quickly identified.
It is wrong to hide the problem to enable incorrect code to be
released to production - and I would not be happy if the first I knew
about it was when a production system administrator complained.
If this is the same problem, you need to daemonize the script