I have a batch file that runs a few processes to test and build my chef cookbooks
del test.tar.gz
berks vendor --delete
berks package test.tar.gz <- doesnt execute
--or--
del test.tar.gz
berks package test.tar.gz
berks vendor --delete <- doesnt execute
the problem is that no commands after the first berks command ever get executed.
I've tried adding several different commands after berks vendor however nothing will run, even though the previous command completes successfully.
I cant find anything in the documentation about this, how can I get all my commands to run?
The binstub we create on Windows is berks.bat. So you need to use call berks.bat instead. This is a weird limitation of Windows batch scripts.
Related
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
I'm try to create a batch file that will, among other things like installing the newest version of our software, first UNINSTALL the old version. I have used "wmic product get name" to find the actual name of the program, and then I have scripted the following code to uninstall the program:
wmic product where "name like 'Borland CaliberRM 10.1'" call uninstall /nointeractive >> C:\users\pbrandvold\Desktop\log.txt
When it's finished, I get this message:
Executing (\\PHIL-BRANDVOLD\ROOT\CIMV2:Win32_Product.IdentifyingNumber="{ED8B0A1F-8E90-478A-82B6-7C885A628257}",Name="Borland CaliberRM 10.1",Version="10.1.0.84")->Uninstall()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
ReturnValue = 1603;
};
I can't think of what is happening - why won't this uninstall? I've also tried using the msi, and running:
msiexec.exe /qn /x "Borland CaliberRM 10.1.msi"
Which doesn't work either.
I had this issue when trying to uninstall and reinstall Web Deploy using wmic via a batch file. It did not help running the batch file with elevated privileges.
The only way I could get it to run correctly was to open a Command Prompt window with elevated privileges and run the batch file through that.
The solution I ended up going with was to turn my batch file into an executable using a Bat to Exe converter. http://www.f2ko.de/en/b2e.php
The issue occurs due to the user's privileged of uninstalling the program.
Just open the command prompt as 'Run as administrator and run your command to uninstall the program.
Example :
open cmd with admin:
run below commands
wmic
product get name
product where name="YOUR_PROGRAM_NAME" call uninstall
I have configured NUnit tests to run after build completed.(Jenkins)
I added following on Excecute windows batch command window in Jenkins.
rmdir ClickOnceInstall /Q /S
mkdir ClickOnceInstall
CD BuildScripts
Start.bat
"C:\Program Files (x86)\NUnit 2.6.2\bin\nunit-console-x86.exe" AA.Tests\bin\x86\Release\AA.Tests.dll /xml=nunit-result.xml
It seems Execute unit test command doesn't create result file as specified name and marked as failed. However, when I run the nunit test command manually it creates the file. Next time build through Jenkins, result xml file does not seem to be updated but it doesn't fail.
am I missing any configuration or something else?
It would help if you would paste the console log.
However, my first guess is to ask you to add call to your batch file statement:
call Start.bat
If that batch file has an exit /b statement (even with 0), it will quit the whole calling step (i.e. "Execute windows batch command") without getting to your last statement (i.e nunit command).
Using call in front of the batch file will make sure that control is returned to the calling step.
I am trying to run this command in jenkins after a MSbuild
xcopy "C:\Program Files (x86)\Jenkins\workspace\trunk\Projects\results\results\obj\Debug\Package\PackageTmp" "Y:\Extraction_Zone\Jenkins\" /E
Y: is a mapped network drive. This runs fine in cmd.exe but when trying to run it in Jenkins, I am getting the error Invalid drive specification.
Here is the output from jenkins:
Time Elapsed 00:00:04.03
[trunk] $ cmd /c call C:\Windows\TEMP\hudson3389873107474371072.bat
C:\Program Files (x86)\Jenkins\workspace\trunk>xcopy "C:\Program Files (x86)\Jenkins\workspace\trunk\Projects\results\results\obj\Debug\Package\PackageTmp" "Y:\Extraction_Zone\Jenkins\" /E
Invalid drive specification
0 File(s) copied
C:\Program Files (x86)\Jenkins\workspace\trunk>exit 4
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
Any help would be appreciated.
I too had a similar issue once. Try granting the Jenkins service "Logon as This account" right under services.msc and make sure the account you type there is the same as the one you use for running cmd.exe.
These commands based on Java JAR files worked for me:
cmd
net use x: \\
xcopy "dist\" x:\ /Y
And that's it! I spent lot of time figure out this issue and nothing worked until I wrote CMD and NET USE!
Neither I didn't need to change permission on jenkins service nor use runas command.
But I must mention that everyone had read and write access to the network drive.
I had the same issue with my Windows Task running a batch file (I know it is not exactly same) where I tried to copy file to network location i.e. shared drive. I used the UNC path and mapped drive as well but the error was same. For me it was error number 4 - MS DOS error code.
The solution was to use net use command! Hope that it helps.
Easy fix for most things.
Make a batch command with what your trying to run, filename.bat with the command prompt text inside.
Make a normal windows shortcut for the batch command, edit the shortcuts advanced properties and check the "Run as admin" (tricky tricky).
Now run the filename.lnk shortcut from jenkins command line call, this will get you around all the jazz.
:)
The solution of adarshr (i.e., modifying the log on credentials of the service) has worked for me for a part of the problem: in my case, this allowed me to successfully check out a mercurial repository (using ssh protocol), which I could not do when using 'Local System account'.
However, I still have different behavior between running a command-line script or running the same script from a jenkins 'execute shell' script in the build section. In my case, I compile a Python extension. In Jenkins, I cannot import the extension (I don't see any error, but the execution simply stops, so I suspect it crashes).
If I uninstall the service and run the slave agent as a Java Web Start, I do get the same behavoir. It is a temporary fix for me, but it means that when I reboot the windows build machine, I have to manually re-start the Java Web Start application.
So -at least in my case- it is clear that this is a credential problem.
Credentials usage documentation: https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI
I've solved my issue with the CIFS plugin.
Faced similar issue and found two ways to solve.
Type 1:
Tell Jenkins about mapped drive.
1.Goto -> Manage Jenkins -> Script Console (Groovy Script).
2.Run below command
def mapdrive = "net use Y: \\\\copy_nework_address"
mapdrive.execute();
println "net use".execute().getText()
Type:2
1.Goto -> cmd -> run "net use" to know network address
xcopy "C:\Program Files (x86)\Jenkins\workspace\trunk\Projects\results\results\obj\Debug\Package\PackageTmp" "Copy_Network_Address\Extraction_Zone\Jenkins\" /E
Conclusion:- I prefer 2nd types as after every restart i should run Groovy Script.
In hudson, after running a .bat script my slave refuses to run anything that comes afterward. It instead just said that it finished with a success.
Trying do a
call yourscript.bat
instead of just a
yourscript.bat