I'm running Jenkins on a Server 2012 VM, and I'm noticing that some of my projects are being marked as incomplete when they are successful. I am getting the error 'The batch file cannot be found.' The problem, from what I can tell, is that the batch file Jenkins is creating to run my project is being deleted before it's completed. I'm migrating from a windows 7 box where this issue doesn't happen.
I've been able to watch as the batch file is created in C:\Users\164016\AppData\Local\Temp\ and then it's deleted before the batch file completes. I'm even able to open the batch file before it's deleted.
I've tried placing the Call command at the beginning of the command, but that doesn't resolve the issue.
The LaunchPad.exe command is a custom made script designed to return exit codes from Excel vba macros.
Please let me know if you have any suggestions.
Here is the log:
Building remotely on (164016) Remote Computer in workspace C:\TEMP\Jenkins Slave\workspace\Weekly Claim Edit WQ Age
[Weekly Claim Edit WQ Age] $ cmd /c call C:\Users\164016\AppData\Local\Temp\hudson3188220465265190989.bat
C:\TEMP\Jenkins Slave\workspace\Weekly Claim Edit WQ Age>"O:\Analytics Team\Tasks\Automation Components\Ryan\C#\Launch Pad\LaunchPad\LaunchPad\bin\Debug\LaunchPad.exe" "C:\Program Files (x86)\Quest Software\Toad for Data Analysts 2.7\Toad.exe" -batch=true "O:\Analytics Team\Tasks\Automation Components\Cindy\TAS\Claim_Edit_WQ_Age.tas" "O:\Analytics Team\Tasks\Claim Edit WQ Age\Claim_Edit_WQ_Age.xlsm"
LaunchPad Start Time: 10.7.2014 9:49:10 AM
Time before Stopping Programs: 60 min
Program: "C:\Program Files (x86)\Quest Software\Toad for Data Analysts 2.7\Toad.exe"
Arguments: "-batch=true" "O:\Analytics Team\Tasks\Automation Components\Cindy\TAS\Claim_Edit_WQ_Age.tas"
vba File: "O:\Analytics Team\Tasks\Claim Edit WQ Age\Claim_Edit_WQ_Age.xlsm"
vba Exit File: O:\Analytics Team\Tasks\Claim Edit WQ Age\Claim_Edit_WQ_Age.txt
Report Completed: 10/7/2014 9:50:28 AM 164016 O:\Reports\EPIC\Epic Claim Edit WQ\20141007 Claim Edit WQ Age.xlsx
Exiting LaunchPad: No Errors Detected: 0
The batch file cannot be found.
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
I had a very similar problem. I was running a job in Jenkins that was calling a specialized internal program and causing the "batch file not found" error. It turns out there was a del %TEMP%\*.* /q command in one of the batch files being run. This was deleting all of the Jenkins temporary batch files in the middle of the job and causing the error.
The simple solution is to simply relocate the Jenkins temp folder. This can be done by adding a command line option to your Jenkins startup script. My startup script looks like: java -XX:MaxPermSize=1024m -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -Djava.io.tmpdir=C:\Users\!!My_user_name!!\Desktop\Jenkins_Temp -jar jenkins.war
The important part I added was the -Djava.io.tmpdir=C:\Users\!!My_user_name!!\Desktop\Jenkins_Temp option (Removed my user name for privacy reasons.) This fixed the problem. Don't forget to replace my path with with a valid path name for your system.
The command line option should be added to both the master and slave startup scripts for proper operation.
You've got something else at play here...
When you configure Execute Windows batch command build step, it creates a temporary batch file that Jenkins then executes.
The execution of the temporary batch file starts at:
[Weekly Claim Edit WQ Age] $ cmd /c call C:\Users\164016\AppData\Local\Temp\hudson3188220465265190989.bat
and it finishes at:
Build step 'Execute Windows batch command' marked build as failure
The temporary batch file hudson3188220465265190989.bat would be deleted after that last line.
Your error The batch file cannot be found. happens before that line. So, it's not the Jenkins temporary batch file that cannot be found, but something else.
Unless you provide the content of your Execute Windows batch command, it's difficult to guess what else could be the problem.
Related
i installed jenkins in c:\program files(x86)\jenkins and am trying to integrate with a helloworld java file. but when i first tried to build from jenkins, itself, its failed.
i went through this link : https://www.youtube.com/watch?v=bGqS0f4Utn4
when i compiled my java file, from the admin cmd prompt, its compiles successfully. but it failed within the jenkins console.
I created a C:\workspace folder and saved the java file, there.
what am doing wrong ? why am getting the wrong path within the console output?
am getting the below error in the console output :
`Console Output
Started by user user1
Running as SYSTEM
[EnvInject] - Loading node environment variables.
Building in workspace C:\Program Files (x86)\Jenkins\workspace\
HelloWorld
[HelloWorld] $ cmd /c call C:\Windows\TEMP\jenkins6223662388306682118.bat
C:\Program Files (x86)\Jenkins\workspace\HelloWorld>cd C:\Workspace
C:\Workspace>javac Hello.java
'javac' is not recognized as an internal or external command,
operable program or batch file.
C:\Workspace>java Hello
'java' is not recognized as an internal or external command,
operable program or batch file.
C:\Workspace>exit 9009
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
First, since you've installed JDK, make sure you've added in system level environment variable
Set JDK bin path in Jenkins > manage jenkins > global tools configurations > jdk installations, then try
mostly this option would help to resolve
i'm using TFS2015 and vnext builds to build projects and sln files with build controller
in projects or slns we use robocopy command to copy dlls from builded solution to other folders but sometimes this job done and vnext build passed successfully and sometimes robocopy command can't copy dlls and failed with error
is there anyone solved this problem, can help me ?
1-my build agents run with Network/Service User
2-robocopy command error exited with code 8.
Error 8 from Robocopy means that some files or directories could not be copied at that moment. Since you are saying that the command sometimes succeeds, more likely is either a specific time related issue, or probably the files are being used by some other process at the time when the command is executed. In both cases you could try to execute the same robocopy command manually several minutes later, and see if it will fail again. You could add a /v option in your robocopy command (and possibly /LOG), and verify if there is more descriptive error in the log file afterwards. Also, when it fails, is the environment same as the one, on which it succeeds?
I have a problem trying to launch a server via a .bat file during a TFS build.
I usually launch the server via a cmd window and it works fine.
When I set it in the TFS build, I end up with the following message :
"'..\server_common.bat' is not recognized as an internal command or external, an executable or a command file".
I also have the following line:
"java -Dsun.lang.ClassLoader.allowArraySyntax=true -Xbootclasspath/a:..\..\..\lib\framework\serverjvm15.jar; -cp ..\..\..\lib\framework\fwtime.jar;" indicating a java syntax error (? I'm not skilled in java)
This batch calls other .bat files and sets java VM-related environment variables
From my research, it is probably a problem of rights as I don't have admin rights when I use TFS. However, all the other steps in the build work fine (installing and launching an appli through command lines, or launching a python script via command lines).
However I also tried to launch a basic script with the same kind of step and it works.
First, suggest you to follow the tutorial in Batch script. Make sure you have meet the requirements of Arguments and used correctly. Such as
Path
Specify the path to the .bat or .cmd script you want to run. The path
must be a fully qualified path or a valid path relative to
the default working directory. In Team Foundation Build, this
directory is $(Build.SourcesDirectory).
Also RDP to your build agent and use your build service account manually run the server_common.bat to narrow down if the account have enough permission.
I trying to run my Tests cases for a project in Jenkins through DOS Command line on Windows server . I am using Jenkins ver. 1.559.
I am trying to run a Windows batch file through a Jenkins job that has the java command.
Under the "Build" section >> "Execute Windows Batch command" >> Command: call E:\Jenkins\App\UnitTests\App_UnitTests.bat
Save and Build the job.
I am getting an error and here is my Console Output
C:\Program Files (x86)\Jenkins\jobs\App Test Cases\workspace>java.exe -cp "E:\Jenkins\App\PPS\App\bin\;E:\Jenkins\App\PPS\App\lib\junit-4.10.jar;E:\Jenkins\App\PPS\App\lib\*.jar;" org.junit.runner.JUnitCore com.omnitracs.fra.junit.EventTests
'java.exe' is not recognized as an internal or external command, operable program or batch file.
C:\Program Files (x86)\Jenkins\jobs\App Test Cases\workspace>PAUSE
Press any key to continue . . .
C:\Program Files (x86)\Jenkins\jobs\App Test Cases\workspace>EXIT
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
The java command runs fine outside Jenkins.
I have set the JAVA_HOME for the local user and also the PATH variable to point to where java.exe is.
What am I doing wrong? Please help.
For a windows environment, there is some extra configuration needed for more advanced builds. Ultimately you have two options
From Jenkins, The Definitive Guide:
This basic installation will work fine in a simple context, but you
will often need to fine-tune your service. For example, by default,
the Jenkins service will be running under the local System account.
However, if you are using Maven, Jenkins will need an .m2 directory
and a settings.xml file in the home directory. Similarly, if you
are using Groovy, you might need a .groovy/lib directory. And so on.
To allow this, and to make testing your Jenkins install easier, make
sure you run this service under a real user account with the correct
development environment set up. Alternatively, run the application as the
system user, but use the System Information page in Jenkins to check
the /Users/johnsmart/Projects/Books/jenkins-thedefinitive- guide
directory, and place any files that must be placed in the user home
directory here....
To configure your Jenkins server to run under a service account (The suggested option), Install Jenkins as a service, and under the services properties set the log on user info.
I have an ant file which has move and copy tasks. The source and destination locations are on the mapped network drive R:\. When I run them on the command prompt the build is successful but when I configure it as a job in Jenkins, the tasks are failing with the below console output.
BUILD FAILED
C:\Users\admin\.jenkins\jobs\CopyTask\workspace\build.xml:24: R:\dest does not exist.
Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
Both the standalone build and Jenkins build are under the same user credentials.
I have looked in the the questions copy in ANT throws java.io.FileNotFoundException and
Ant Copy Task: Failed to copy due to java.io.FileNotFoundException but it didn't help me solve the issue.
EDIT
Jenkins service was running under local system account and in Jenkins app, I was using "Jenkins's own user database" for Security Realm. I had created a user called "admin" with all the permissions granted. After looking in to this link, I installed Active Directory Plugin and used an administrator account credentials to start the Jenkins service. But still I am getting the below error message
BUILD FAILED
C:\Users\admin\.jenkins\workspace\CopyTask\build.xml:11:
Failed to copy C:\Users\admin\FldrToCopy\data.7z to
R:\data.7z due to failed to create the parent directory for R:\data.7z
Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
Obviously, the system account you're using doesn't have this mapped drive. Before copying, try to map the drive through the Windows net use command. In Jenkins, you can run this in your build steps as a shell command before you execute your Ant script.
I don't have a Windows machine in front of me, but it should look something like this:
net use R: /delete
net use R: /persistent:yes \\windows\share\path
You want to do the net use R: /delete first to remove any already existing mapping.
If this doesn't work, try this. This will help you create a mapped drive to your system account that always exist.
What user account is Jenkins running as? If it's running as the SYSTEM account, then it probably can't see the mapped drive. Take a look at Map a network drive to be used by a service for some ideas.
Or perhaps you could use the UNC path instead of the mapped drive?