Running a bat file in Jenkins - batch-file

I am trying to run a bat file to start a server as follows:
cd c:\...\bin
call asadmin start-domain
This should start the server. It works great with command prompt, but it is not working when I am using the same commands with Jenkins. It is a freestyle project.
When I run the build it says "attempting to the start domain..." and then completes the build with status "success", but the server is still not started.
I would be grateful, if someone could guide me in this regard.
Thank you in advance,
Fred

Related

Run minecraft server minimized through BAT

so recently I've made a function that launches my server when someone asks for it, but I don't want it to disrupt me while I'm playing, let's say,
Is there any way to start the server seamlessly ?
I use this BAT file to launch it through python.
cd C:\Users\MYUSERNAME\OneDrive\Bureau\Serv\Xection
java -Xmx4096M -Xms4096M -jar server.jar
Thanks in advance
EDIT : Stupid question, you just need to add "nogui" after server.jar
i would suggest using autoit scripting.here is a oneliner that will start your program hidden.Download autoit from here.after downloading autoit,create a file named whatever.au3 and past the following code with your path.
Run("Your program path", "", #SW_HIDE)
just run the script and it will start the executable hidden as a process.

Writing Batch file that monitors a certain web page's status

The issue
I am trying to create a batch file that will execute the following two commands:
cd /some/path
dotnet run
that produces the following output:
It starts my localhost server.
Trying To Accomplish
What I would like to do is, put those two commands in a batch file and automatically open Chrome to the server address, HOWEVER, the dotnet command takes some time to finish. So somehow, I would have to keep monitoring localhost to see if it is available.
Any help would be appreciated. Although opening a CMD window, typing those 2 commands, and waiting a minute isn't all that much of a problem, it sure would be nice to just click on a batch file.
Thank you.
You can create a batch file like this code :
#echo off
Set "ApplicationPath=%UserProfile%\source\repos\PruttPos\PruttPosSystem\"
CD /D "%ApplicationPath%"
dotnet run
Start "Chrome" Chrome.exe "http://localhost:5000"
pause

Start selenium slave on start-up using batch file

I am trying to create a batch file that will connect slave node to master jenkins on boot.
I can successfully connect by manually typing:
java -jar slave.jar -jnlpUrl http://jenkinsURL:8080/jenkins/computer/Selenium%20Slave/slave-agent.jnlp -secret secret key
But when I try running the script that has the exact same command, it returns Failing to obtain http://jenkinsurl:8080/jenkins/computer/Selenium0Slave/slave-agent.jnlp?encrypt=true and fails to process the connection.
Batch script:
start cmd /k java -jar slave.jar -jnlpUrl http://jenkinsurl:8080/jenkins/computer/Selenium%20Slave/slave-agent.jnlp -secret secretkey
Why does it return different URL when executed with a batch file?
If anyone has successfully done this I would really appreciate your feedback. Thanks!

How to run a batch file from Jenkins

I am trying to run a batch file from Jenkins but I can't get it to run.
In the pre-build step I have entered the file I want to execute but I get the stacktrace shown below. Jenkins doesn't recognize the cmd command.
How can I fix this?
Your Linux Jenkins slave doesn't support cmd. In order to workaround it you have several options (from better to worse):
Add a Windows slave to Jenkins and run cmd from there.
Port your batch file to bash or similar and run it from your Linux Jenkins slave.
Add some kind of DOS emulator (Wine, DOSBox, DOSemu) in your Linux Jenkins slave.
My advice: If you know Linux & Bash or you have no control of Jenkins go for option 2. Otherwise go for option 1. Avoid option 3.
You're trying to run CMD on a LINUX machine. either change the slave you're running to Windows machine or migrate the Batch script to shell script.
Good luck!

TFS Post Build script executing twice

I have a post build batch file being executed after a TFS build. It compiles an Inno Setup script and places the generated exe in a drop folder. It then tries to run that exe and install the application on the server. It runs the exe; however, this hangs the build.
The issue is, it seems to execute it twice. I can see 2 process running for the installer in task manager. If I execute the batch file manually, there are no issues - it's only when TFS executes it, I run into this problem.
Post Build Batch File
cd "C:\Program Files (x86)\Inno Setup 5"
iscc "%scriptDir%\Script.iss"
cd "C:\Deployment"
start Installer.exe /VERYSILENT
Any ideas would be greatly appreciated. Scratching my head with this.
From my findings, the post build script was NOT executing twice.
I believe the issue had something to do with permissions. The build service was being executed via the LocalService account which did not have permission to install the application. I THINK the build service tried to execute the installer but was denied and silently failed (and possibly tried again causing the additional installer process).
Solution: Set the Build Service to run under a different account with the permissions to install applications.

Resources