0

I am currently in the process of implementing a deployment method using Teamcity, which runs a Powershell script on my Build Agent, which then configures my Production environment etc.

I have a problem with the Powershell script though, in that it can't seem to run the batch file from it.

The script runs perfectly if I run it manually, it only fails when run via TeamCity.

In the build log I am getting the error:

'myBatchFile.bat' is not recognized as an internal or external command, operable program or batch file.

The batch file and the powershell script are in the same directory and the batch file is called as such:

cmd /c Deploy.bat

I have my TeamCity configuration set up to have the build step for this as:

  • Script: File
  • ScriptExecutionMode: Execute script with -File argument
  • Script Arguments: None
  • Additional CMD line params: None

I had originally not used the cmd to try to execute the batch file, but executing the batch file like .\Deploy.bat did not seem to work either.

Is there an additional thing I need to set up in order to get the batch file to run? The rest of the script runs fine, just the call to the batch that doesn't.

2
  • where you put Deploy.bat? Commented Feb 15, 2013 at 9:04
  • The Deploy.bat and the powershell script are both in the same folder Commented Feb 15, 2013 at 9:07

1 Answer 1

2

This is a bit of a wild stab as it's difficult to predict what's happening, but from the description it seems like the path is been altered in the script and it's also dynamic as TeamCity creates temp directories, but if you replace:

cmd /c Deploy.bat

with

cmd /c "$(Split-Path $myinvocation.MyCommand.Path)\Deploy.bat"

then I think this will be able to located the deploy script. Let me know how it goes.

Sign up to request clarification or add additional context in comments.

2 Comments

thank you, this fixed it for my powershell script. Just need to fix the new problems it created in the batch file ;)
lol, that's the fun part of IT, you fix one thing and something else breaks. :-) Let me know if you need any help on that part as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.