Jenkins windows slave batch job says success but job did not run - perl

Trying to set up a jenkins v2.46.3 slave on windows 2016 server to run a batch file.
It looks like it is working but the batch file does not actually run. The script does not generate the expected log file and nothing shows up in task manager on the slave
The console output of the job looks like this:
Started by user xxx
Building remotely on xxx-Windows (windows) in workspace c:\Jenkins\workspace\xxx
[xxx] $ cmd /c call C:\Windows\TEMP\hudson4948156451026881586.bat
c:\Jenkins\workspace\xxx>C:\QA\xxx\Perl\Tests\runxxxTests.bat
c:\Jenkins\workspace\xxx>cd C:\QA\xxx\Perl\Tests
C:\QA\xxx\Perl\Tests>runxxxTests.pl -f test_suite_test.list
Finished: SUCCESS
If I run the batch file manually it works as expected.
There do not seem to be any errors. How can I troubleshoot this further ?

The fix to this was changing the log on rights of the Jenkins and Jenkins Agent services on the windows slave from LocalSystem to a privileged account.

Related

Execute powershell script with gitlab-runner on local windows machine

I do have following setup:
a win PC with gitlab-runner installed (working)
a powershell script running on the same PC is starting an application
a gitlab server to connect this local PC and starting the powershell script
Now when starting the powershell script directly from the local PC, the application starts and terminates after done - working as expected. When starting the same powershell script with the gitlab server (yml-file) then I can see that the application has been started (new process in taskmanager) but it is not running as well it never terminates.
When manually end the task I see that gitlab terminates again.
Question:
what could be the root cause?
is it possible to run the powershell script with gitlab-runner? I think there is a way with the command "exec". How does the command looks like when calling the powershell script?
is it possible to run the application not in the background in order to see whats going on?
others?
thanks in advance
I think there is a bug with the gitlab runner on windows.
No matter which shell you configure in the config.toml the runner
will always use cmd.exe for an exec local run.
Specify the --shell argument to override the default cmd.exe shell:
> gitlab-runner exec shell your_job --shell pwsh
If you run this locally in your project, it outputs to .builds/, so add this to your .gitignore because git will see it and think you might want to add a submodule.

Script not running via Task Scheduler

I have to deploy some Perl automation scripts on a server. But to schedule them I am using Windows Task Scheduler. I have a .bat file in which I have written the command
perl scriptname.pl
Provided the .bat file and script are in same directory which is in D: drive. But the task scheduler always triggers and then gives error that previous instance is already running.
I don't want to override the instance but I cannot see any instance running. Also the script is a selenium script and I am not seeing any browser window which I generally see when the task is triggered by the Scheduler.
The script is working fine on excuting the .bat file directly.

How to invoke an opened Exceed window to run a Perl script using a Schedule Task

TASK TO BE ACCOMPLISHED:
To schedule a perl script which is executed on a specific time / day in a week
THINGS I HAVE DONE:
In a schedule Tasks, I have created a new Task by which the Task will call a batch file with below contents
cd "DRIVE\FOLDER\Hummingbird\Connectivity\14.00\Exceed\"
ABCD.xs
cd mDrive/bin
perl baseline.pl -publish -location XXX -email
THINGS NOT WORKING FOR ME / CAUSING THE ISSUE:
Wen I run the scheduler, the prompt opens up the ABCD.xs exceed file window seperately file but the below commands are executed in the command pronpt itself
EXPECTED OUTPUT:
I want the commands
cd mDrive/bin
perl baseline.pl -publish -location XXX -email
to be executed in the exceed window
Any kind of solution wud be great
Thanks in advance.
Haresh
Sounds like you need to start getting into either SendKey stuff (Win32 packages) or else look into writing Exceed/Hummingbird scripts and just executing those.
Some other things to look into... does the remote server have a telnet or ssh server running? Or are there other methods of executing code on the remote server?
For example, my work's mainframe is accessed via a Hummingbird terminal emulator, but I can also telnet to the mainframe and execute commands as well as FTP batch job directly into the JES spool. So when I execute things on the mainframe by way of my PC (Perl scripts, etc.), I don't even fool with Hummingbird.
Good luck...

Running a .bat file in Scheduled Task

I am using a Windows Server 2008 machine where I need to run a batch file as a Scheduled Task. The scheduled batch file is not running, but when I click the batch file manually its running with no problem.
The Content of the batch file is as follows:
cd E:\SOAPUI\soapui-2.0.2\bin
e:
testrunner.bat -sDev_Test -a -j -f "D:\DocRepos\LensWebSvc\SOAPUI-Reports(Lens)"
"D:\DocRepos\LensWebSvc\SOAPUI\LensWebServiceTest(Lens)-soapui-project.xml"
Can anyone help me to run the batch file in scheduled task?
It could be a few things. Make sure you've set the task to start in the same path that the batch file is located. Also, make sure the account running the task has permission to run the task and access the location of the batch file.

How do I get Powershell to execute in scheduled task?

I have created a Powershell script and set it up to run within a .bat file. When I click on the .bat file the Powershell script runs like a champ. I then set up the .bat file to be run as a scheduled task. Again it works like a champ when I right click on it and launch it interactively. Problem is it fails when the task scheduled to run unattended in the evening.
Not sure if this matters but I am using Powershell v.1 on Windows 2003 Server 64.
Thanks in advance for your help.
==========================================
The status on the scheduled task is "Could not start". Perhaps fails was the wrong choice of words because the task probably doesn't even start running.
The task is set up to run as my user and I am set up as a local administrator on the box.
Check if scheduled task's security setting
Scheduled task might be running under a credential that does not have access to the batch file.
When you are adding a new task, you are asked to enter a credential
And you can check for already created task's credential
[UPDATE]
The status on the scheduled task is "Could not start". Perhaps fails was the wrong choice of words because the task probably doesn't even start running.
Make sure that Task Scheduler service is running
Is the task set to run with your useraccount or as System? Check the access rights on cmd.exe and powershell.exe.
Also if you go to the sheduled tasks you can do a 'view log' in the advanced menu to check for error messages.
Just a guess, but could it be something to do with the account/security context from which the script is running? If it's running on the System account, then that could certainly be a problem. (I suspect it's just running on your user account however.) Check that all your path variables are set correctly when the script runs, for a start. Otherwise, could you perhaps provide any more information on how exactly it fails (i.e. any error messages)?
Maybe the current directory is not set as you expect when running from the task manager. Try running your bat file from the command line, while you are not in the same directory as the file (and your .ps1 script) are.
Otherwise: check permissions.