-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for associating WebHook templates with Projects
This allows a WebHook Template to be created and associated with a project rather then just _Root. Now group admins can create templates for use with their own webhooks. This addresses issue #131 Note: WebHook Template Ids must be unique across a teamcity instance, even if the user creating the template is not aware and is not permissioned to see an existing template with that ID. - Uses templateId rather than templateName when referring to ID. - Added projectId field and getProjectId method to templates. - Added validators and permissions - Fixed up permissions for template editing in REST API - Added Templates to WebHook Project tab - Added Templates list to Webhook Project Config tab. - Added Project Name and link to Templates page. - WebHooks now resolve project specific templates when building payload.
- Loading branch information
Showing
27 changed files
with
2,159 additions
and
1,661 deletions.
There are no files selected for viewing
142 changes: 71 additions & 71 deletions
142
...ooks-rest-api-legacy/src/main/java/webhook/teamcity/server/rest/WebHookApiUrlBuilder.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 |
---|---|---|
@@ -1,71 +1,71 @@ | ||
package webhook.teamcity.server.rest; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import jetbrains.buildServer.server.rest.PathTransformer; | ||
import jetbrains.buildServer.server.rest.util.ValueWithDefault.Value; | ||
import webhook.teamcity.server.rest.data.WebHookTemplateItemConfigWrapper.WebHookTemplateItemRest; | ||
import webhook.teamcity.server.rest.request.TemplateRequest; | ||
import webhook.teamcity.server.rest.request.WebHooksRequest; | ||
import webhook.teamcity.server.rest.util.webhook.WebHookManager; | ||
import webhook.teamcity.settings.WebHookConfig; | ||
import webhook.teamcity.settings.config.WebHookTemplateConfig; | ||
|
||
/** | ||
* Adds the WebHooks urls into the resolver. | ||
* @author netwolfuk | ||
* | ||
*/ | ||
public class WebHookApiUrlBuilder { | ||
|
||
private PathTransformer myPathTransformer; | ||
|
||
public WebHookApiUrlBuilder(@NotNull final PathTransformer pathTransformer) { | ||
myPathTransformer = pathTransformer; | ||
} | ||
|
||
public String getHref(final WebHookTemplateConfig template) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateHref(template)); | ||
} | ||
|
||
public String getHref(String projectExternalId, WebHookConfig config) { | ||
return myPathTransformer.transform(WebHooksRequest.getWebHookHref(projectExternalId, config)); | ||
} | ||
|
||
public String getTemplateDefaultItemHref(WebHookTemplateConfig WebHookTemplateConfig) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateDefaultItemHref(WebHookTemplateConfig)); | ||
} | ||
|
||
public String getTemplateItemHref(WebHookTemplateConfig WebHookTemplateConfig, WebHookTemplateItemRest webHookTemplateItem) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateItemHref(WebHookTemplateConfig, webHookTemplateItem)); | ||
} | ||
|
||
public String getDefaultTemplateTextHref(final WebHookTemplateConfig template) { | ||
return myPathTransformer.transform(TemplateRequest.getDefaultTemplateTextHref(template)); | ||
} | ||
|
||
public String getDefaultBranchTemplateTextHref(final WebHookTemplateConfig template) { | ||
return myPathTransformer.transform(TemplateRequest.getDefaultBranchTemplateTextHref(template)); | ||
} | ||
|
||
public String getTemplateItemTextHref(WebHookTemplateConfig WebHookTemplateConfig, WebHookTemplateItemRest webHookTemplateItem) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateItemTextHref(WebHookTemplateConfig, webHookTemplateItem)); | ||
} | ||
|
||
public String getTemplateItemBranchTextHref(WebHookTemplateConfig WebHookTemplateConfig, WebHookTemplateItemRest webHookTemplateItem) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateItemBranchTextHref(WebHookTemplateConfig, webHookTemplateItem)); | ||
} | ||
|
||
public String transformRelativePath(final String internalRelativePath) { | ||
return myPathTransformer.transform(internalRelativePath); | ||
} | ||
|
||
public String getWebHookTemplateStateUrl(WebHookTemplateConfig template, String state) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateStateHref(template, state)); | ||
} | ||
|
||
public String getWebHookTemplateItemStateUrl(WebHookTemplateConfig template, WebHookTemplateItemRest templateItem, String state) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateItemStateHref(template, templateItem, state)); | ||
} | ||
|
||
} | ||
package webhook.teamcity.server.rest; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import jetbrains.buildServer.server.rest.PathTransformer; | ||
import jetbrains.buildServer.server.rest.util.ValueWithDefault.Value; | ||
import webhook.teamcity.server.rest.data.WebHookTemplateItemConfigWrapper.WebHookTemplateItemRest; | ||
import webhook.teamcity.server.rest.request.TemplateRequest; | ||
import webhook.teamcity.server.rest.request.WebHooksRequest; | ||
import webhook.teamcity.server.rest.util.webhook.WebHookManager; | ||
import webhook.teamcity.settings.WebHookConfig; | ||
import webhook.teamcity.settings.config.WebHookTemplateConfig; | ||
|
||
/** | ||
* Adds the WebHooks urls into the resolver. | ||
* @author netwolfuk | ||
* | ||
*/ | ||
public class WebHookApiUrlBuilder { | ||
|
||
private PathTransformer myPathTransformer; | ||
|
||
public WebHookApiUrlBuilder(@NotNull final PathTransformer pathTransformer) { | ||
myPathTransformer = pathTransformer; | ||
} | ||
|
||
public String getHref(final WebHookTemplateConfig template) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateHref(template)); | ||
} | ||
|
||
public String getHref(String projectExternalId, WebHookConfig config) { | ||
return myPathTransformer.transform(WebHooksRequest.getWebHookHref(projectExternalId, config)); | ||
} | ||
|
||
public String getTemplateDefaultItemHref(WebHookTemplateConfig WebHookTemplateConfig) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateDefaultItemHref(WebHookTemplateConfig)); | ||
} | ||
|
||
public String getTemplateItemHref(WebHookTemplateConfig WebHookTemplateConfig, WebHookTemplateItemRest webHookTemplateItem) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateItemHref(WebHookTemplateConfig, webHookTemplateItem)); | ||
} | ||
|
||
public String getDefaultTemplateTextHref(final WebHookTemplateConfig template) { | ||
return myPathTransformer.transform(TemplateRequest.getDefaultTemplateTextHref(template)); | ||
} | ||
|
||
public String getDefaultBranchTemplateTextHref(final WebHookTemplateConfig template) { | ||
return myPathTransformer.transform(TemplateRequest.getDefaultBranchTemplateTextHref(template)); | ||
} | ||
|
||
public String getTemplateItemTextHref(WebHookTemplateConfig WebHookTemplateConfig, WebHookTemplateItemRest webHookTemplateItem) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateItemTextHref(WebHookTemplateConfig, webHookTemplateItem)); | ||
} | ||
|
||
public String getTemplateItemBranchTextHref(WebHookTemplateConfig WebHookTemplateConfig, WebHookTemplateItemRest webHookTemplateItem) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateItemBranchTextHref(WebHookTemplateConfig, webHookTemplateItem)); | ||
} | ||
|
||
public String transformRelativePath(final String internalRelativePath) { | ||
return myPathTransformer.transform(internalRelativePath); | ||
} | ||
|
||
public String getWebHookTemplateStateUrl(WebHookTemplateConfig template, String state) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateStateHref(template, state)); | ||
} | ||
|
||
public String getWebHookTemplateItemStateUrl(WebHookTemplateConfig template, WebHookTemplateItemRest templateItem, String state) { | ||
return myPathTransformer.transform(TemplateRequest.getTemplateItemStateHref(template, templateItem, state)); | ||
} | ||
|
||
} |
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
Oops, something went wrong.