add run type for publish packages runner
authorEugene Petrenko <eugene.petrenko@gmail.com>
Thu, 21 Jul 2011 10:22:16 +0000 (14:22 +0400)
committerEugene Petrenko <eugene.petrenko@gmail.com>
Thu, 21 Jul 2011 11:53:25 +0000 (15:53 +0400)
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/PackagesInstallerRunner.java
nuget-common/src/jetbrains/buildServer/nuget/common/PackagesConstants.java
nuget-server/src/META-INF/build-server-plugin-nuget.xml
nuget-server/src/jetbrains/buildServer/nuget/server/install/PackagesInstallerRunType.java
nuget-server/src/jetbrains/buildServer/nuget/server/publish/PublishRunType.java [new file with mode: 0644]
nuget-server/src/jetbrains/buildServer/nuget/server/publish/PublishRunTypeRegistrar.java [new file with mode: 0644]

index c677035000f70c849288b7ffe7f615c8947e810a..23999409400b7dbafe4e25c90e8ce1ab7858d0e3 100644 (file)
@@ -87,7 +87,7 @@ public class PackagesInstallerRunner implements AgentBuildRunner, AgentBuildRunn
 \r
   @NotNull\r
   public String getType() {\r
 \r
   @NotNull\r
   public String getType() {\r
-    return PackagesConstants.RUN_TYPE;\r
+    return PackagesConstants.INSTALL_RUN_TYPE;\r
   }\r
 \r
   public boolean canRun(@NotNull BuildAgentConfiguration agentConfiguration) {\r
   }\r
 \r
   public boolean canRun(@NotNull BuildAgentConfiguration agentConfiguration) {\r
index 62dad9afedc3ecf0a90399bb0fb30a439e4aebef..2453d88d6e97a849d0d6b81db0919511abd8c1a5 100644 (file)
@@ -24,7 +24,8 @@ import jetbrains.buildServer.agent.Constants;
  * Date: 07.07.11 13:56\r
  */\r
 public interface PackagesConstants {\r
  * Date: 07.07.11 13:56\r
  */\r
 public interface PackagesConstants {\r
-  public static final String RUN_TYPE = "jetbrains.nuget.packagesInstaller";\r
+  public static final String INSTALL_RUN_TYPE = "jetbrains.nuget.packagesInstaller";\r
+  public static final String PUBLISH_RUN_TYPE = "jetbrains.nuget.publish";\r
 \r
 \r
   public static final String NUGET_PATH = "nuget.path";\r
 \r
 \r
   public static final String NUGET_PATH = "nuget.path";\r
index 741a391d65539402802cb163b616600cf5fc6625..603fd6f08a5dc72c626a3e15e5c08dca43519c96 100644 (file)
@@ -26,4 +26,8 @@
 \r
 \r
   <bean class="jetbrains.buildServer.nuget.server.show.NuGetDownloadedPackagesTab"/>\r
 \r
 \r
   <bean class="jetbrains.buildServer.nuget.server.show.NuGetDownloadedPackagesTab"/>\r
+\r
+\r
+  <bean class="jetbrains.buildServer.nuget.server.publish.PublishRunTypeRegistrar"/>\r
+  <bean class="jetbrains.buildServer.nuget.server.publish.PublishRunType"/>\r
 </beans>
\ No newline at end of file
 </beans>
\ No newline at end of file
index 89b4aecbabbc36c9f87f7737d0881e35104441f8..872ee4820e4e2f4e92630512e0dd7aa1ff4dd69a 100644 (file)
@@ -44,7 +44,7 @@ public class PackagesInstallerRunType extends RunType {
   @NotNull\r
   @Override\r
   public String getType() {\r
   @NotNull\r
   @Override\r
   public String getType() {\r
-    return RUN_TYPE;\r
+    return INSTALL_RUN_TYPE;\r
   }\r
 \r
   @Override\r
   }\r
 \r
   @Override\r
diff --git a/nuget-server/src/jetbrains/buildServer/nuget/server/publish/PublishRunType.java b/nuget-server/src/jetbrains/buildServer/nuget/server/publish/PublishRunType.java
new file mode 100644 (file)
index 0000000..20d72ec
--- /dev/null
@@ -0,0 +1,108 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.server.publish;\r
+\r
+import jetbrains.buildServer.nuget.common.DotNetConstants;\r
+import jetbrains.buildServer.nuget.common.PackagesConstants;\r
+import jetbrains.buildServer.requirements.Requirement;\r
+import jetbrains.buildServer.requirements.RequirementType;\r
+import jetbrains.buildServer.serverSide.InvalidProperty;\r
+import jetbrains.buildServer.serverSide.PropertiesProcessor;\r
+import jetbrains.buildServer.serverSide.RunType;\r
+import jetbrains.buildServer.util.StringUtil;\r
+import jetbrains.buildServer.web.openapi.PluginDescriptor;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.util.*;\r
+\r
+import static jetbrains.buildServer.nuget.common.PackagesConstants.NUGET_API_KEY;\r
+import static jetbrains.buildServer.nuget.common.PackagesConstants.NUGET_PATH;\r
+import static jetbrains.buildServer.nuget.common.PackagesConstants.NUGET_PUBLISH_FILES;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 21.07.11 14:15\r
+ */\r
+public class PublishRunType extends RunType {\r
+  private final PluginDescriptor myDescriptor;\r
+\r
+  public PublishRunType(@NotNull final PluginDescriptor descriptor) {\r
+    myDescriptor = descriptor;\r
+  }\r
+\r
+  @NotNull\r
+  @Override\r
+  public String getType() {\r
+    return PackagesConstants.PUBLISH_RUN_TYPE;\r
+  }\r
+\r
+  @Override\r
+  public String getDisplayName() {\r
+    return "NuGet Publish Packages";\r
+  }\r
+\r
+  @Override\r
+  public String getDescription() {\r
+    return "Pushes and publishes NuGet package to a given feed";\r
+  }\r
+\r
+  @Override\r
+  public PropertiesProcessor getRunnerPropertiesProcessor() {\r
+    return new PropertiesProcessor() {\r
+      public Collection<InvalidProperty> process(Map<String, String> properties) {\r
+        final List<InvalidProperty> checks = new ArrayList<InvalidProperty>();\r
+\r
+        if (StringUtil.isEmptyOrSpaces(properties.get(NUGET_PATH))) {\r
+          checks.add(new InvalidProperty(NUGET_PATH, "Path to nuget.exe must be specified"));\r
+        }\r
+\r
+        if (StringUtil.isEmptyOrSpaces(properties.get(NUGET_API_KEY))) {\r
+          checks.add(new InvalidProperty(NUGET_API_KEY, "API key must be specified"));\r
+        }\r
+\r
+        if (StringUtil.isEmptyOrSpaces(properties.get(NUGET_PUBLISH_FILES))) {\r
+          checks.add(new InvalidProperty(NUGET_API_KEY, "Specify at least one package to pusblish"));\r
+        }\r
+\r
+        return checks;\r
+      }\r
+    };\r
+  }\r
+\r
+  @Override\r
+  public String getEditRunnerParamsJspFilePath() {\r
+    return myDescriptor.getPluginResourcesPath("publish/editPublish.jsp");\r
+  }\r
+\r
+  @Override\r
+  public String getViewRunnerParamsJspFilePath() {\r
+    return myDescriptor.getPluginResourcesPath("publish/viewPublish.jsp");\r
+  }\r
+\r
+  @Override\r
+  public Map<String, String> getDefaultRunnerProperties() {\r
+    return Collections.emptyMap();\r
+  }\r
+\r
+  @Override\r
+  public List<Requirement> getRunnerSpecificRequirements(@NotNull Map<String, String> runParameters) {\r
+    List<Requirement> list = new ArrayList<Requirement>(super.getRunnerSpecificRequirements(runParameters));\r
+    list.add(new Requirement(DotNetConstants.DOT_NET_FRAMEWORK_4_x86, null, RequirementType.EXISTS));\r
+    return list;\r
+  }\r
+\r
+}\r
diff --git a/nuget-server/src/jetbrains/buildServer/nuget/server/publish/PublishRunTypeRegistrar.java b/nuget-server/src/jetbrains/buildServer/nuget/server/publish/PublishRunTypeRegistrar.java
new file mode 100644 (file)
index 0000000..28ed353
--- /dev/null
@@ -0,0 +1,31 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.server.publish;\r
+\r
+import jetbrains.buildServer.serverSide.RunTypeRegistry;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 21.07.11 14:20\r
+ */\r
+public class PublishRunTypeRegistrar {\r
+  public PublishRunTypeRegistrar(@NotNull final PublishRunType rt,\r
+                                 @NotNull final RunTypeRegistry reg) {\r
+    reg.registerRunType(rt);\r
+  }\r
+}\r