re-implement hide of nuget api key in build logs, add more tests for it
[teamcity/dotNetPackagesSupport.git] / nuget-agent / src / jetbrains / buildServer / nuget / agent / commands / impl / NuGetActionFactoryImpl.java
index d27aee8f2a9de293e9acde79341db83611421d81..3e5f94a52cea58828de52c885efb56b61e55479a 100644 (file)
@@ -16,6 +16,7 @@
 \r
 package jetbrains.buildServer.nuget.agent.commands.impl;\r
 \r
+import com.intellij.openapi.diagnostic.Logger;\r
 import jetbrains.buildServer.RunBuildException;\r
 import jetbrains.buildServer.agent.BuildFinishedStatus;\r
 import jetbrains.buildServer.agent.BuildProcess;\r
@@ -26,10 +27,13 @@ import jetbrains.buildServer.nuget.agent.dependencies.PackageUsages;
 import jetbrains.buildServer.nuget.agent.parameters.*;\r
 import jetbrains.buildServer.nuget.agent.util.BuildProcessBase;\r
 import jetbrains.buildServer.nuget.agent.util.CommandlineBuildProcessFactory;\r
+import jetbrains.buildServer.util.StringUtil;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
 import java.io.File;\r
+import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.List;\r
 import java.util.Map;\r
 \r
 /**\r
@@ -37,6 +41,8 @@ import java.util.Map;
  * Date: 07.07.11 17:49\r
  */\r
 public class NuGetActionFactoryImpl implements NuGetActionFactory {\r
+  private static final Logger LOG = Logger.getInstance(NuGetActionFactoryImpl.class.getName());\r
+\r
   private final CommandFactory myCommandFactory;\r
   private final CommandlineBuildProcessFactory myFactory;\r
   private final PackageUsages myPackageUsages;\r
@@ -54,11 +60,22 @@ public class NuGetActionFactoryImpl implements NuGetActionFactory {
       @NotNull\r
       public BuildProcess createCommand(@NotNull File program,\r
                                         @NotNull File workingDir,\r
-                                        @NotNull Collection<String> argz,\r
+                                        @NotNull Collection<String> _argz,\r
                                         @NotNull Map<String, String> additionalEnvironment) throws RunBuildException {\r
+        String cmd = context.getBuildParameters().getEnvironmentVariables().get("ComSpec");\r
+        if (StringUtil.isEmptyOrSpaces(cmd)) {\r
+          LOG.warn("Failed to find path to cmd.exe in %ComSpec% environment variable");\r
+          cmd = "cmd.exe";\r
+        }\r
+\r
+        List<String> argz = new ArrayList<String>();\r
+        argz.add("/c");\r
+        argz.add(program.getPath());\r
+        argz.addAll(_argz);\r
+\r
         return myFactory.executeCommandLine(\r
                 context,\r
-                program,\r
+                cmd,\r
                 argz,\r
                 workingDir,\r
                 additionalEnvironment\r