I want to stop and start WebLogic from Jenkins. If I start by shell script in Jenkins:
./startWebLogic.sh
the process is not finished, but WebLogic is started.
If I start by shell script with nohup in Jenkins:
. ./setWLSEnv.sh
nohup ./startWebLogic.sh > /dev/null &
the process is finished, but WebLogic is not started.
I tried the same script on the same server from putty, in result process is finished and WebLogic is started.
How I can start WebLogic and execute other shell script from Jenkins.
It worked for me. But this code has one issue. When you put your process in background you can't see logs of the process. And if your weblogic couldn't start at all you will know that only on the further stages (trying to deploy - in my case).
stage('Start WLS') {
steps {
sh '${DOMAIN_BIN_DIR}/startWebLogic.sh &'
}
}
Hope, someone will give a better solution with ability to determine the fact of Weblogic's fall on the running stage.
Related
I've recently updated git bash to 2.35.1. I do Minecraft plugin/server development so am often using git bash to start and manage test servers in windows. Unfortunately I do not know what version I was on before.
Now when I started a server using java -Xms4G -Xmx4G -jar server.jar it boots, but I can't type anything into the console. I am completely locked out. Using CTRL+C will shutdown the server but it says "do you want to terminate the batch job" and hangs. I have to force quit the java process.
Before, I could type game console commands in without issue.
I've tried running git bash as administrator, no change. PowerShell doesn't work at all, it won't even show the output of the console after starting the jar.
When I stop the server from in-game, I get this error after it fully stops:
$ stop
bash: stop: command not found
I am trying to automate a SpringBoot Application through Jenkins.
I have myApp.jar and currently, I run it using the following command
nohup java -jar myApp.jar &
Press Ctrl^C or Ctrl^Z and process keep running in the background.
Logs will be added in nohup.out
Now I want the same process to be done using Jenkins.
In Jenkins, build section, I have selected Execute Shell Script with the above command.
When build is triggered. I can see Application startup Log in Jenkins Log but the problem is, build never finishes.
I have tried
BUILD_ID=dontKillMe timeout --foreground 30 nohup java -jar website-status.jar &
also
BUILD_ID=dontKillMe nohup java -jar website-status.jar &
timeout is killing the process. I don't want process to be killed.
Edit 1:
I have tried this as well. Build keeps running.
JENKINS_NODE_COOKIE=dontKillMe nohup java -jar website-status.jar &
When we execute command like this
nohup java -jar myApp.jar &
a prompt is shown saying log will be written in nohup.out file and this was causing the script to hang forever in Jenkins.
I changed the command and now no prompt and works fine, logs are written in server.log
nohup java -jar myApp.jar >> server.log 2>&1&
I want my JBoss server to run in background, for that I am using nohup ./startPID.sh > /dev/null 2>&1& command. But when I pass same command in Jenkins, it doesn't work as expected. The console output in Jenkins says "command ran successfully" but in backend the JBoss server is still down.
Any inputs?
Regards
Manish Mehra
Use "at now" instead of "nohup"
In your job jenkins (execute shell) put :
set +e #so "at now" will run even if java -jar fails
#Run java app in background
echo "java -jar $(ls | grep *.jar | head -n 1)" | at now + 1 min
You could look at the JBoss management plugin
which spins up JBoss for you
This plugin allows to manage a JBoss Application Server during build
procedure.
With the plugin we can start/stop JBoss AS. It's very useful if we
need to run some integration tests against of the server. There is
also operation allows verification if artifacts are deployable.
It looks to be quite an old plugin but has cuurent users
I am using the "Send files or execute commands over SSH after the build runs" option in my Jenkins job configuration. I am running a .bat file on a remote server. The .bat file is starting an authentication server. The authentication server needs to remain up and running on the remote server.
The authentication server is delivered with a .bat file to start and stop the server. When I run the delivered .bat file my jenkins job hangs and never completes. The delivered .bat file named startAuth.bat looks like this:
call java -jar Auth.jar db migrate Auth.yml
call java -jar Auth.jar server Auth.yml
Based on some end user restrictions, I cannot modify the startAuth.bat file, so I have create another .bat file to call startAuth.bat named runStartAuth.bat. It looks like this:
cd c:\tmp
start runStartAuth.bat
exit /b
My thinking was by using "start" the .bat should be run in a separate process, one that could remain up and running until the next Jenkins job run, and the calling .bat would exit with the exit /b line. Unfortunately, the Jenkins job seems to ignore the exit and just spins and spins.
What am I doing wrong?
I'm not really an expert with Jenkins ... but I think since the slave agent JVM wrapper over your batch file knows that the child process has not yet finished, it will not return control to the executor.
Instead, can you try having the same commands on the Jenkins slave node configuration ? I believe you will have slave launcher prefix command in the Advanced section of the slave node.
I have a build job on jenkins that is building my project and after it is done, it opens an ssh shell script on a remote server and transfers files and then stop and starts a daemon.
When I stop and start the daemon from the command line on a RHEL server, it executes just fine. When the job executes in jenkins, there are no errors.
The daemon stops fine and it starts fine. But shortly after starting, the daemon dies suddenly.
sudo service daemonName stop
# transfer files.
sudo service daemonName start
I'm sure that the problem isn't pathing
Does anyone know what could be special about the way Jenkins is executing the ssh shell script that would cause the daemon start to not fully complete?
The problem:
When executing a build through jenkins, the command to start the daemon process was clearly successfully executing, yet after the build job was done, the daemon would suddenly quit.
The solution:
I thought for this whole time that it was jenkins killing the daemon. So I tried many different incarnations and permutations of disabling the ProcessTree module that goes through and cleans up zombie child processes. I tried fooling it by resetting the BUILD_ID environment variable. Nothing worked.
Thanks to this thread I found out that that solution only works for child processes executed on the BUILD machine. I.E. not applicable to my problem.
More searching led me here: Run a persistent process via ssh
The solution? Nohup.
So now the build successfully restarts the daemon by executing the following:
sudo nohup service daemonname start
Jenkins watches for processes spawned by the job and kill them to avoid zombie processes.
See https://wiki.jenkins-ci.org/display/JENKINS/ProcessTreeKiller
The workaround is to override the BUILD_ID environment variable:
BUILD_ID=dontKillMe