0

I am trying to deploy a zip file to nexus using deploy:deploy-file but maven still not happy about this and is complaining about a missing project/pom file. Below is the code snippet and debug log

$params =
            @(
                "deploy:deploy-file",
                "-X",
                "-e",
                "-DartifactId=${env:ZIP_PREFIX}",
                "-Dmaven.wagon.provider.http=httpclient",
                "-Durl=http://abc-nexus.repo.net:9081/repository/releases-prod-dist",
                "-DrepositoryId=releases-prod-dist",
                "-DgroupId=$nexusPath",
                "-Dversion=$fullVersion",
                "-Dpackaging=zip",
                "-Dfile=$reviewArea\$zipName"
            )

            Start-Process "java" -ArgumentList @("-version") -Wait -NoNewWindow
            Start-Process "mvn" -ArgumentList @("-version") -Wait -NoNewWindow
            

            Write-Output "Start-Process mvn -NoNewWindow -Wait -ArgumentList ${params}"
            Start-Process mvn -NoNewWindow -PassThru -Wait -ArgumentList $params

2020-09-11T06:17:27.7943241Z [INFO] Scanning for projects...
2020-09-11T06:17:27.9140863Z [DEBUG] Extension realms for project org.apache.maven:standalone-pom:pom:1: (none)
2020-09-11T06:17:27.9466573Z [DEBUG] Looking up lifecycle mappings for 
packaging pom from ClassRealm[plexus.core, parent: null]
2020-09-11T06:17:27.9641628Z [INFO] ------------------------------------------------------------------------
2020-09-11T06:17:27.9643764Z [INFO] BUILD FAILURE
2020-09-11T06:17:27.9645595Z [INFO] ------------------------------------------------------------------------
2020-09-11T06:17:27.9684029Z [INFO] Total time: 0.250 s
2020-09-11T06:17:27.9689684Z [INFO] Finished at: 2020-09-10T23:17:27-07:00
2020-09-11T06:17:28.0604956Z [INFO] Final Memory: 6M/245M
2020-09-11T06:17:28.0608153Z [INFO] ------------------------------------------------------------------------
2020-09-11T06:17:28.0695335Z [ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\AzureRemoteAgent\_work\r16\a). Please verify you invoked Maven from the correct directory. -> [Help 1]
2020-09-11T06:17:28.0700315Z org.apache.maven.lifecycle.MissingProjectException: The goal you specified requires a project to execute but there is no POM in this directory (C:\AzureRemoteAgent\_work\r16\a). Please verify you invoked Maven from the correct directory.
2020-09-11T06:17:28.0703641Z     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:85)
2020-09-11T06:17:28.0708399Z     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
2020-09-11T06:17:28.0710747Z     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
2020-09-11T06:17:28.0712639Z     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
2020-09-11T06:17:28.0714330Z     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
2020-09-11T06:17:28.0716002Z     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
2020-09-11T06:17:28.0717718Z     at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
2020-09-11T06:17:28.0719285Z     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
2020-09-11T06:17:28.0721040Z     at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
2020-09-11T06:17:28.0723365Z     at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
2020-09-11T06:17:28.0725220Z     at java.lang.reflect.Method.invoke (Method.java:498)
2020-09-11T06:17:28.0727008Z     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
2020-09-11T06:17:28.0729074Z     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
2020-09-11T06:17:28.0731080Z     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
2020-09-11T06:17:28.0733229Z     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Redline1111
  • 131
  • 2
  • 11

1 Answers1

0

Atleast in Powershell, every argument needs to be enclosed in double quotes. I ended up doing single quotes around arguments that don't have variables and backticks around the ones that do. This preserves the double quotes in arguments and variables are expanded.

 $params =
            @(
                '"deploy:deploy-file"',
                '"-X"',
                '"-e"',
                "`"-DartifactId=${env:ZIP_PREFIX}`"",
                '"-Dmaven.wagon.provider.http=httpclient"',
                '"-Durl=http://abc-nexus.repo.net:9081/repository/releases-prod-dist"',
                '"-DrepositoryId=releases-prod-dist"',
                "`"-DgroupId=$nexusPath`"",
                "`"-Dversion=$fullVersion`"",
                '"-Dpackaging=zip"',
                "`"-Dfile=$parentDir\$zipName`""
            )
Redline1111
  • 131
  • 2
  • 11