I want to build with maven my java projects on TFS Build Server. TFS Build Definition use invokeprocess in workflow. invokeprocess able to run powershell script and command batch file.
Maven build successed with "mvn assembly:assembly -P prod
" command in windows command prompt. But does not success in powershell. (I connected to server with remote and executed on powershell ise) (either as a regular user or as an administrator)
I installed Maven 3.1.1 and Java Dev Kit 6 update 45 on Windows 2012 Standart 64-bit machine.We use NTLM authentication and proxy.
I defined following configuration:
Environment settings:
JAVA_HOME C:\Program Files\Java\jdk1.6.0_45
M2 %M2_HOME%\bin
M2_HOME C:\Program Files\Apache Software Foundation\apache-maven-3.1.1
Path:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;%TFSPowerToolDir%;%BPADir%;%M2%;%JAVA_HOME%\bin
maven settings.xml:
<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>proxy.xxx.entp</host>
<port>8080</port>
<username>myuser</username>
<password>mypassword</password>
<nonProxyHosts>*.xxx.entp|localhost</nonProxyHosts>
</proxy>
</proxies>
</settings>
The following is my powershell script:
# mvn clean install
# mvn assembly:assembly –P prod
Set-ExecutionPolicy Unrestricted -Force
$mvnArgs1 ="mvn assembly:assembly –P prod -Dmaven.test.skip=true".replace('-P','`-P').replace('-D','`-D')
Invoke-Expression $mvnArgs1
The following is the output in powershell:
please click the image of output powershell
how to maven works in powershell? Or any way?
> mvn -version 'mvn' is not recognized as an internal or external command, operable program or batch file. Answer: Refer to Step 4, make sure the %MAVEN_HOME%\bin is added to the PATH system variable. Answer: Refer to Step 2, make sure JDK is installed and the JAVA_HOME system variable is configured.
Call it something sensible, like "Calculator". Open up a command prompt and navigate to your calculator directory Run npm init to create a new Node. js project. Use the default answer to every question it asks you (just press "Enter") - don't worry if you don't understand what all the questions mean!
You don't need Invoke-Expression, see my blog post: http://blogs.msdn.com/b/powershell/archive/2011/06/03/invoke-expression-considered-harmful.aspx
In your case, just run the command almost exactly like you would in cmd (it turns out you probably need to add some quotes):
mvn assembly:assembly -P prod "-Dmaven.test.skip=true"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With