Allowiing Jenkins restart from webapp when started from command line - windows

I have a windows installation of Jenkins, and I run it as regular logged in user on the desktop via java -jar jenkins.war.
Restarting it remotely via the web interface (going to http://jenkins/safeRestart) gives me the following exception:
javax.servlet.ServletException: hudson.lifecycle.RestartNotSupportedException: Default Windows lifecycle does not support restart.
Is it possible to allow remote restart even when not running as a service?

Related

Installing JBOSS EAP 7.4 on Windows Server – Account and Shutdown problems

I´m trying to install JBOSS EAP 7.4 on Windows Server as a service and I´m having trouble with two issues. All batch files where executed from the command line (cmd.exe) in admin mode.
Installation of Service with local system account
I´m using the service.bat to install it as a service. When checking in the properties of the service for the user context, it says it was installed under a Local Service user.This leads to numerous errors in the startup log, as the service is not allowed to access the file system in R/W mode. Manually setting this to “Local System Account” solves the problem, it runs just fine.
So, how do I configure the installation script that the service will use “Local System Account” or, how can I grant R/W access to this “Local Service”?
Shutdown
The manual states, that you must use the parameter /jbossuser (and password) for the installation. If I don´t, it is not possible to shut down the service via the Windows Services Tool, timeout…
If I add a user to the installation, it can be shutdown. As long as it runs in the “Local Service” context. If I change it to Local System Account, it doesn´t shutdown anymore, timeout…
Beside, this is a productive installation on a virtual server. It will not be possible to have a permanent, dedicated user on such a machine.
How do I configure this correctly?
Current installation params, generated by the service.bat:
"D:\jboss-eap-7.4.6\jboss-eap-7.4\bin\prunsrv.exe" install MyApp
--DisplayName=MyApp
--Description="JBoss Enterprise Application Platform 7"
--LogLevel=INFO
--LogPath="D:\jboss-eap-7.4.6\jboss-eap-7.4\standalone\log"
--LogPrefix=service
--StdOutput=auto
--StdError=auto
--StartMode=exe
--Startup=manual
--StartImage=cmd.exe
--StartPath="D:\jboss-eap-7.4.6\jboss-eap-7.4\bin" ++StartParams="/c#set#NOPAUSE=Y#&&#standalone.bat#-Djboss.server.base.dir=D:\jboss-eap-7.4.6\jboss-eap-7.4\standalone#--server-config=standalone.xml"
--StopMode=exe
--StopImage=cmd.exe
--StopPath="D:\jboss-eap-7.4.6\jboss-eap-7.4\bin"
++StopParams="/c jboss-cli.bat --controller=localhost:9990 --connect --user=ABC --password='12345' --command=:shutdown"
Any help is appreciated!

How can I force Selenium tests running on a jenkins slave-node to run in the foreground?

I have a CentOS server running a Jenkins server that has a connection to slave-node running windows server 2016. the Jenkins server has a job that is configured to run a series of Selenium tests on the slave-node.
for the launch method of the slave-node configuration i am using "Launch Agent by connecting it to the master" and I've setup the slave-node create the connection on startup.
the tests can run successfully but when I remote into the windows-slave node via RDP and start the build from the Jenkins server I am unable to see a browser launch and show see the Selenium test interact with the webpage unless I re-lauch the slave-agent within the Remote Desktop connection.
I have tried to running the Jenkins slave-agent as a windows service and also tried starting it with a batch script running at startup but I get the same result.
java -jar agent.jar -jnlpUrl http://{Jenkins Server URL}/computer/{Jenkins Node}/slave-agent.jnlp
is there any way to have the slave-agent run at start-up but also have Desktop interaction when the when I start the Selenium test from a Jenkins build?
Did you try launching the agents using JNLP through windows task scheduler? For trigger you can select multiple options including launch the agent when some one logs into through the RDP session.

Unable to execute the windows bash script on Jenkins slave

As a part of regression testing need to run the bash script on windows machine which actually open the chrome browser and traverse the website and generate the test report.
when i try to execute it through jenkins all the test cases are getting failed as its unable to open the browser, the same is getting passed when we logon to the remote windows server and execute the script manually.
NOTE: Have provided the same credentials on jenkins slave windows service
found below log on event manager
Activation of app Microsoft.Windows.Cortana_cw5n1h2txyewy!CortanaUI failed with error: This app can't be activated by the Built-in Administrator. See the Microsoft-Windows-TWinUI/Operational log for additional information.
Could you please help me here..
Hi can you enable the option Allow service to interact with desktop for the jenkins slave service on your windows slave machine.
You can enable it by going In services.msc > right click on service name > Properties > Log On > Allow service to interact with desktop

Jenkins Windows slave gives Unexpected Error with JNLP start

I have a Jenkins server running happily on a Windows server. I need to connect 2 other windows servers as slaves.
One connects in fine (start using JNLP, then installed as a Windows service).
The other fails to connect using JNLP. Whether I use the Launch button or the javaws command line it fails with 'Unexpected Error - Unable to launch Slave Agent for {node}'. If I start the slave using the headless command line it works, so I suspect it's not networking/firewall related.
I'd like to get the JNLP launch working so I can install it as a Windows service.
Other notes:
the Jenkins URL is set OK
we're using Matrix security, but anonymous has Slave/Connect
Any help gratefully received.

Jenkins : Selenium GUI tests are not visible on Windows

When I run my selenium test (mvn test) from jenkins (windows) I see only the console output. I don't see the real browsers getting opened . How can I configure jenkins so that I can see the browsers running the test?
I had the same problem, i got the solution after many attempts.
This solution works ONLY on windows XP
If you are using jenkins as a windows service you need to do the following :
1) In windows service select the service of jenkins
2) Open properties window of the service -> Logon-> enable the checkbox "Allow service to interact with desktop"
After then you should reboot the service jenkins
Hope this help you :)
UPDATE:
Actually, I'm working on a an automation tool using Selenium on Windows 10, I've installed Jenkins ver. 2.207 as windows application (EXE file), it's running as windows service and ALL drivers (Chrome, FireFox, IE) are visible during test executions WITHOUT performing a mere configuration on the System or Jenkins
I got the solution. I ran jenkins from command prompt as "java -jar jenkins.war" instead of the windows installer version. Now I can see my browser based tests being executed.
If you are already doing what #Sachin suggests in a comment (i.e. looking at the machine where Jenkins actually runs) and still do not see the browsers, then your problem may be the following:
If you run Jenkins as a service in the background it won't open apps in the foreground. You may either try to run it not as a service in the foreground, or run it as a Local System account and check Allow the service to interact with desktop option. In the latter case you may get into permission problems, though.
Update: To make sure this answer is understood properly by others: Jenkins Windows 'native' installation is not really native. It's a wrapper around Java that runs it as a service.
To interact with desktop GUI, you should launch slave agent via JNLP:
https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds#Distributedbuilds-LaunchslaveagentviaJavaWebStart
After adding the node in Jenkins (configured as Java Web Start launch), just make a startup batch script on the node machine:
java -jar slave.jar -jnlpUrl http://{Your Jenkins Server}:8080/computer/{Your Jenkins Node}/slave-agent.jnlp
(slave.jar can be downloaded from http://{Your Jenkins Server}:8080/jnlpJars/slave.jar)
See more answers here:
How to run GUI tests on a jenkins windows slave without remote desktop connection?
In the case of Windows 7 you should not install jenkins as windows application (because in this recent version, Microsoft decided to give services their own hidden desktop even you enable the functionality "interact with desktop" in jenkins service), you may have to deploy it from a war file as follows:
1) Download jenkins.war from Jenkins official site
2) Deploy it by the command prompt : java -jar {directoryOfJenkinsFile}/jenkins.war
3) Now you can access jenkins administration on http:// localhost:8080
Hope that helps you !
this is an issue for Jenkins. on Windows it is possible to access logon user's session (screen) under system account. to make the UI testing visible, Jenkins needs to bypass UAC (user access
control) at background. this solution works for me with my own service running as system account.
I also faced the same issue earlier in my local machine (Windows 10).
My test was running perfectly from the NetBeans but when I moved to Jenkins it was only running in console mode. I was unable to view the UI.
So for that, you just need to make your local machine as a Jenkins slave by creating a new slave node in your Jenkins and select that node to execute the Jenkins job.
If jenkins installed by windows installer it is showing only Console out put only. To see browsers download jenkins.war file and run java -jar jenkins.war from command line.
Go through this site:
http://learnseleniumtesting.com/jenkins-and-continuous-test-execution/
If you have the following situation,
You are able to login to the remote machine
You don't see the Jenkins agent window
This slave machine is accessed by many users then try the following,
then try the following suggestion.
Login to slave machine
Go to Task manager
Users
Logout all the users
Then login again.
This worked for me.

Resources