-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We have a simple server side support for the plugin
- Loading branch information
Showing
24 changed files
with
591 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.cprieto.octocity.common; | ||
|
||
public final class Util { | ||
private Util() {} | ||
|
||
public static boolean IsNullOrWitespace(String input) { | ||
return input == null || input.trim().length() == 0; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
common/src/test/java/com/cprieto/octocity/common/UtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.cprieto.octocity.common; | ||
|
||
import org.testng.annotations.Test; | ||
import static org.testng.Assert.*; | ||
|
||
@Test | ||
public class UtilTest { | ||
public void testItCanValidateNullStrings(){ | ||
assertTrue(Util.IsNullOrWitespace(null)); | ||
} | ||
|
||
public void testItCanValidateEmptyStrings() { | ||
assertTrue(Util.IsNullOrWitespace("")); | ||
} | ||
|
||
public void testItCanVaidateOnlySpaceStrings() { | ||
assertTrue(Util.IsNullOrWitespace(" ")); | ||
} | ||
|
||
public void testItPassWithNonEmptyOrWhitespaceStrings() { | ||
assertFalse(Util.IsNullOrWitespace("hola")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
task assemblePlugin(type: Copy, dependsOn: jar) { | ||
from project.configurations.plugin | ||
from jar.outputs.files | ||
into "${project.distsDir}/plugin" | ||
} |
10 changes: 10 additions & 0 deletions
10
server/src/main/java/com/cprieto/octocity/server/DescriptionPropertyValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.cprieto.octocity.server; | ||
|
||
import com.cprieto.octocity.common.PropertyNames; | ||
|
||
public class DescriptionPropertyValidator extends RequiredPropertyValidator { | ||
public DescriptionPropertyValidator() { | ||
super(PropertyNames.PACKAGE_DESCRIPTION, "Description cannot be empty"); | ||
} | ||
} | ||
|
30 changes: 30 additions & 0 deletions
30
server/src/main/java/com/cprieto/octocity/server/OctocityPropertyProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.cprieto.octocity.server; | ||
|
||
import jetbrains.buildServer.serverSide.InvalidProperty; | ||
import jetbrains.buildServer.serverSide.PropertiesProcessor; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class OctocityPropertyProcessor implements PropertiesProcessor { | ||
private final List<PropertyValidator> validators; | ||
|
||
public OctocityPropertyProcessor(@NotNull List<PropertyValidator> validators) { | ||
this.validators = validators; | ||
} | ||
|
||
@Override | ||
public Collection<InvalidProperty> process(@NotNull Map<String, String> properties) { | ||
Collection<InvalidProperty> errors = new HashSet<InvalidProperty>(); | ||
|
||
for(PropertyValidator validator : validators) { | ||
InvalidProperty result = validator.hasErrors(properties); | ||
if (result != null) errors.add(result); | ||
} | ||
|
||
return errors; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
server/src/main/java/com/cprieto/octocity/server/OctocityRunType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.cprieto.octocity.server; | ||
|
||
import com.cprieto.octocity.common.PluginConstants; | ||
import com.cprieto.octocity.common.PropertyNames; | ||
import jetbrains.buildServer.serverSide.Parameter; | ||
import jetbrains.buildServer.serverSide.PropertiesProcessor; | ||
import jetbrains.buildServer.serverSide.RunType; | ||
import jetbrains.buildServer.serverSide.RunTypeRegistry; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class OctocityRunType extends RunType { | ||
private final OctocityPropertyProcessor processor; | ||
|
||
public OctocityRunType(@NotNull final RunTypeRegistry registry, @NotNull OctocityPropertyProcessor processor) { | ||
this.processor = processor; | ||
registry.registerRunType(this); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return PluginConstants.RUNNER_TYPE; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return PluginConstants.RUNNER_NAME; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return PluginConstants.RUNNER_DESCRIPTION; | ||
} | ||
|
||
@Override | ||
public PropertiesProcessor getRunnerPropertiesProcessor() { | ||
return processor; | ||
} | ||
|
||
@Override | ||
public String getEditRunnerParamsJspFilePath() { | ||
return ViewNames.EDIT_PARAMETERS; | ||
} | ||
|
||
@Override | ||
public String getViewRunnerParamsJspFilePath() { | ||
return ViewNames.VIEW_PARAMETERS; | ||
} | ||
|
||
@Override | ||
public Map<String, String> getDefaultRunnerProperties() { | ||
return new HashMap<String, String>() {{ | ||
put(PropertyNames.PACKAGE_VERSION, "%build.number%"); | ||
}}; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
server/src/main/java/com/cprieto/octocity/server/OwnersPropertyValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.cprieto.octocity.server; | ||
|
||
import com.cprieto.octocity.common.PropertyNames; | ||
|
||
public class OwnersPropertyValidator extends RequiredPropertyValidator { | ||
|
||
public OwnersPropertyValidator() { | ||
super(PropertyNames.PACKAGE_OWNERS, "You need to tell us who is the package owner"); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
server/src/main/java/com/cprieto/octocity/server/PackageIdValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.cprieto.octocity.server; | ||
|
||
import com.cprieto.octocity.common.PropertyNames; | ||
import com.cprieto.octocity.common.Util; | ||
import jetbrains.buildServer.serverSide.InvalidProperty; | ||
|
||
import java.util.Map; | ||
|
||
public class PackageIdValidator implements PropertyValidator { | ||
@Override | ||
public InvalidProperty hasErrors(Map<String, String> properties) { | ||
String packageId = properties.get(PropertyNames.PACKAGE_ID); | ||
if (Util.IsNullOrWitespace(packageId)) | ||
return new InvalidProperty(PropertyNames.PACKAGE_ID, "You need to specify a package id"); | ||
|
||
if (!packageId.matches("^[a-zA-Z.]+$")) | ||
return new InvalidProperty(PropertyNames.PACKAGE_ID, "A valid package id can only contains letters and periods"); | ||
|
||
return null; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
server/src/main/java/com/cprieto/octocity/server/PackageVersionValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.cprieto.octocity.server; | ||
|
||
import com.cprieto.octocity.common.PropertyNames; | ||
import com.cprieto.octocity.common.Util; | ||
import jetbrains.buildServer.serverSide.InvalidProperty; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
|
||
public class PackageVersionValidator implements PropertyValidator { | ||
@Override | ||
public InvalidProperty hasErrors(@NotNull Map<String, String> properties) { | ||
String packageVersion = properties.get(PropertyNames.PACKAGE_VERSION); | ||
if (Util.IsNullOrWitespace(packageVersion)) | ||
return new InvalidProperty(PropertyNames.PACKAGE_VERSION, "You need to specify a package version"); | ||
|
||
if (!packageVersion.matches("^(\\d+\\.)?(\\d+\\.)?(\\d+\\.)?(\\d+)$")) | ||
return new InvalidProperty(PropertyNames.PACKAGE_VERSION, "Are you sure this is a valid package version?"); | ||
|
||
return null; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
server/src/main/java/com/cprieto/octocity/server/PropertyValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.cprieto.octocity.server; | ||
|
||
import jetbrains.buildServer.serverSide.InvalidProperty; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
|
||
public interface PropertyValidator { | ||
InvalidProperty hasErrors(@NotNull Map<String, String> properties); | ||
} |
26 changes: 26 additions & 0 deletions
26
server/src/main/java/com/cprieto/octocity/server/RequiredPropertyValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.cprieto.octocity.server; | ||
|
||
import com.cprieto.octocity.common.PropertyNames; | ||
import com.cprieto.octocity.common.Util; | ||
import jetbrains.buildServer.serverSide.InvalidProperty; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
|
||
public abstract class RequiredPropertyValidator implements PropertyValidator { | ||
private final String _propertyName; | ||
private final String _errorMessage; | ||
|
||
public RequiredPropertyValidator(String propertyName, String errorMessage) { | ||
_propertyName = propertyName; | ||
_errorMessage = errorMessage; | ||
} | ||
|
||
@Override | ||
public InvalidProperty hasErrors(@NotNull Map<String, String> properties) { | ||
if (Util.IsNullOrWitespace(properties.get(_propertyName))) | ||
return new InvalidProperty(_propertyName, _errorMessage); | ||
return null; | ||
} | ||
} | ||
|
6 changes: 6 additions & 0 deletions
6
server/src/main/java/com/cprieto/octocity/server/ViewNames.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.cprieto.octocity.server; | ||
|
||
public interface ViewNames { | ||
String EDIT_PARAMETERS = "editParameters.jsp"; | ||
String VIEW_PARAMETERS = "viewParameters.jsp"; | ||
} |
25 changes: 25 additions & 0 deletions
25
server/src/main/resources/META-INF/build-server-plugin-octocity.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans | ||
xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:lang="http://www.springframework.org/schema/lang" xmlns:aop="http://www.springframework.org/schema/aop" | ||
xmlns:context="http://www.springframework.org/schema/context" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd | ||
http://www.springframework.org/schema/lang | ||
http://www.springframework.org/schema/lang/spring-lang-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd" | ||
default-autowire="constructor"> | ||
<bean id="octocityRunType" class="com.cprieto.octocity.server.OctocityRunType"> | ||
<constructor-arg index="1" ref="octocityPropertyProcessor" /> | ||
</bean> | ||
<bean id="octocityPropertyProcessor" class="com.cprieto.octocity.server.OctocityPropertyProcessor"> | ||
<constructor-arg> | ||
<list> | ||
<bean class="com.cprieto.octocity.server.DescriptionPropertyValidator"/> | ||
<bean class="com.cprieto.octocity.server.OwnersPropertyValidator"/> | ||
<bean class="com.cprieto.octocity.server.PackageIdValidator"/> | ||
<bean class="com.cprieto.octocity.server.PackageVersionValidator"/> | ||
</list> | ||
</constructor-arg> | ||
</bean> | ||
</beans> |
59 changes: 59 additions & 0 deletions
59
server/src/main/resources/buildServerResources/editParameters.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<%@ taglib prefix="props" tagdir="/WEB-INF/tags/props" %> | ||
<%@ taglib prefix="forms" tagdir="/WEB-INF/tags/forms" %> | ||
<%@ taglib prefix="l" tagdir="/WEB-INF/tags/layout" %> | ||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | ||
|
||
<jsp:useBean id="propertiesBean" scope="request" type="jetbrains.buildServer.controllers.BasePropertiesBean"/> | ||
|
||
<l:settingsGroup title="Octopus Nuget Package properties"> | ||
<tr> | ||
<th> | ||
<label for="octocity.id">Package id: <l:star/></label> | ||
</th> | ||
<td> | ||
<props:textProperty name="octocity.id" className="longField" /> | ||
<span class="error" id="error_octocity.id"></span> | ||
<span class="smallNote">Package identifier (eg. package.id)</span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th> | ||
<label for="octocity.title">Title: </label> | ||
</th> | ||
<td> | ||
<props:textProperty name="octocity.title" className="longField" /> | ||
<span class="error" id="error_octocity.title"></span> | ||
<span class="smallNote">Package title (eg. 'This is an awesome package')</span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th> | ||
<label for="octocity.version">Version: <l:star/></label> | ||
</th> | ||
<td> | ||
<props:textProperty name="octocity.version" className="longField" /> | ||
<span class="error" id="error_octocity.version"></span> | ||
<span class="smallNote">Package version (eg. 1.2.3)</span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th> | ||
<label for="octocity.owners">Onwers: <l:star/></label> | ||
</th> | ||
<td> | ||
<props:textProperty name="octocity.owners" className="longField" /> | ||
<span class="error" id="error_octocity.owners"></span> | ||
<span class="smallNote">Package owners (eg. 'superman, batman')</span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th> | ||
<label for="octocity.description">Description: <l:star/></label> | ||
</th> | ||
<td> | ||
<props:textProperty name="octocity.description" className="longField" /> | ||
<span class="error" id="error_octocity.description"></span> | ||
<span class="smallNote">Package description (eg. 'This is a nice deployment package')</span> | ||
</td> | ||
</tr> | ||
</l:settingsGroup> |
Empty file.
Oops, something went wrong.