Start selenium slave on start-up using batch file - 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!

Related

FileZilla Pro CLI Batch command file not executing

I am currently attempting to use FileZilla Pro CLI on a Windows machine to connect and upload to a site in that is working in the Site Manager.
The issue is, the command below works perfectly when pasting it directly into the cmd line. However when saving it as a batch file, it simply just gets to the fzcli> prompt and then nothing happens.
The two line breaks are on purposes to override the requirement for a password and it works perfectly when pasted in.
Does anyone know if this is a cmd line issue, or if my commands need to be different to work in batch file mode?
fzcli
connect --site 0testsite01
put C:/inetpub/wwwroot/websites/sftp/files/customer/test-01.txt /test-sftp/testuser01/test/test-01-uploaded.txt
PAUSE
Your batch file executes fzcli in an interactive mode. The fzcli then waits for you to interactively enter the commands. Only after you would exit the fzcli, the batch file would continue. And fail, as it will try to execute connect as a batch file command. The fzcli does not know about the batch file. Nor does the batch file interpreter know about the fzcli commands.
It's a common misconception. You will find plenty of similar questions basically about scripting any tool that has its own commands. For example: sftp, ftp, psftp, winscp.
To provide commands to fzcli, it seems that you need to use --script switch. The fzcli documentation gives this example:
fzcli --mode standalone --script C:\Scripts\script-file

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

Running a bat file in Jenkins

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

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!

.bat Script Terminating Before AWS Auto Scaling Commands Executed

I am fairly new to Amazon Cloud Auto Scaling (and AWS all together).
I am currently trying to write a .bat script that will automatically create a launch configuration and then an auto scaler. The aim is for an image that was previously set up about a week ago by a coworker.
The problem I encounter is that when I run the script, no commands past the launch configuration command is executed.
The code is here:
echo Beginning Auto Scale Up Process
REM Create a launch config
as-create-launch-config --image-id ami-xxxxxxx --instance-type t1.micro --user-data "Created by Launch Config reportingServerScaleUp-lc" --launch-config reportingServerScaleUp-lc
echo Timer Complete
I am looking for suggestions to help me debug this issue. Or advice on how to solve it. After the "echo Timer Complete" I have a command to create an auto scaler. Though, not even the "echo Timer Complete" is executed. The console does return indicating that the launch configuration is created though :)
Also, when I enter each command sequentially into the command line, each executes perfectly. The launch configuration is created as is the auto scale group.
It turns out that the AWS commands call exit which exits the .bat script prematurely.
Prepending each AWS command with "call" did the trick.
I found suggestions in this question: Why does only the first line of this Windows batch file execute but all three lines execute in a command shell?

Resources