Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-48596] Example of selecting events from UI
- Loading branch information
Showing
11 changed files
with
294 additions
and
2 deletions.
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
17 changes: 17 additions & 0 deletions
17
src/main/java/org/jenkinsci/plugins/registry/notification/events/EventType.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,17 @@ | ||
package org.jenkinsci.plugins.registry.notification.events; | ||
|
||
import hudson.EnvVars; | ||
import hudson.model.AbstractDescribableImpl; | ||
import hudson.model.Run; | ||
import org.jenkinsci.plugins.registry.notification.webhook.WebHookPayload; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public abstract class EventType extends AbstractDescribableImpl<EventType> { | ||
|
||
public abstract boolean accepts(WebHookPayload payload); | ||
|
||
public void buildEnvironment(@Nonnull Run r, @Nonnull EnvVars envs) { | ||
//No-Op | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/org/jenkinsci/plugins/registry/notification/events/EventTypeDescriptor.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 org.jenkinsci.plugins.registry.notification.events; | ||
|
||
import hudson.ExtensionList; | ||
import hudson.model.Descriptor; | ||
import org.jenkinsci.plugins.registry.notification.webhook.WebHookPayload; | ||
|
||
public abstract class EventTypeDescriptor extends Descriptor<EventType> { | ||
|
||
public static final String ENVIRONMENT_KEY = WebHookPayload.PREFIX + "EVENT"; | ||
|
||
public EventTypeDescriptor(Class<? extends EventType> clazz) { | ||
super(clazz); | ||
} | ||
|
||
public EventTypeDescriptor() { | ||
} | ||
|
||
|
||
public static ExtensionList<EventTypeDescriptor> all() { | ||
return ExtensionList.lookup(EventTypeDescriptor.class); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/org/jenkinsci/plugins/registry/notification/events/impl/ManifestDeleted.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,40 @@ | ||
package org.jenkinsci.plugins.registry.notification.events.impl; | ||
|
||
import hudson.EnvVars; | ||
import hudson.Extension; | ||
import hudson.model.Run; | ||
import org.jenkinsci.plugins.registry.notification.Messages; | ||
import org.jenkinsci.plugins.registry.notification.events.EventType; | ||
import org.jenkinsci.plugins.registry.notification.events.EventTypeDescriptor; | ||
import org.jenkinsci.plugins.registry.notification.webhook.WebHookPayload; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class ManifestDeleted extends EventType { | ||
|
||
@DataBoundConstructor | ||
public ManifestDeleted() { | ||
} | ||
|
||
@Override | ||
public boolean accepts(WebHookPayload payload) { | ||
return false; //TODO | ||
} | ||
|
||
@Override | ||
public void buildEnvironment(@Nonnull Run r, @Nonnull EnvVars envs) { | ||
envs.put(EventTypeDescriptor.ENVIRONMENT_KEY, "MANIFEST_DELETED"); //TODO perhaps something more appropriate? | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends EventTypeDescriptor { | ||
public DescriptorImpl() { | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return Messages.EventType_ManifestDeleted_DisplayName(); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/org/jenkinsci/plugins/registry/notification/events/impl/ManifestPushed.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,40 @@ | ||
package org.jenkinsci.plugins.registry.notification.events.impl; | ||
|
||
import hudson.EnvVars; | ||
import hudson.Extension; | ||
import hudson.model.Run; | ||
import org.jenkinsci.plugins.registry.notification.Messages; | ||
import org.jenkinsci.plugins.registry.notification.events.EventType; | ||
import org.jenkinsci.plugins.registry.notification.events.EventTypeDescriptor; | ||
import org.jenkinsci.plugins.registry.notification.webhook.WebHookPayload; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class ManifestPushed extends EventType { | ||
|
||
@DataBoundConstructor | ||
public ManifestPushed() { | ||
} | ||
|
||
@Override | ||
public boolean accepts(WebHookPayload payload) { | ||
return false; //TODO | ||
} | ||
|
||
@Override | ||
public void buildEnvironment(@Nonnull Run r, @Nonnull EnvVars envs) { | ||
envs.put(EventTypeDescriptor.ENVIRONMENT_KEY, "MANIFEST_PUSHED"); //TODO perhaps something more appropriate? | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends EventTypeDescriptor { | ||
public DescriptorImpl() { | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return Messages.EventType_ManifestPushed_DisplayName(); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...n/java/org/jenkinsci/plugins/registry/notification/events/impl/SecurityScanCompleted.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,40 @@ | ||
package org.jenkinsci.plugins.registry.notification.events.impl; | ||
|
||
import hudson.EnvVars; | ||
import hudson.Extension; | ||
import hudson.model.Run; | ||
import org.jenkinsci.plugins.registry.notification.Messages; | ||
import org.jenkinsci.plugins.registry.notification.events.EventType; | ||
import org.jenkinsci.plugins.registry.notification.events.EventTypeDescriptor; | ||
import org.jenkinsci.plugins.registry.notification.webhook.WebHookPayload; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class SecurityScanCompleted extends EventType { | ||
|
||
@DataBoundConstructor | ||
public SecurityScanCompleted() { | ||
} | ||
|
||
@Override | ||
public boolean accepts(WebHookPayload payload) { | ||
return false; //TODO | ||
} | ||
|
||
@Override | ||
public void buildEnvironment(@Nonnull Run r, @Nonnull EnvVars envs) { | ||
envs.put(EventTypeDescriptor.ENVIRONMENT_KEY, "Security_Scan_Completed"); //TODO perhaps something more appropriate? | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends EventTypeDescriptor { | ||
public DescriptorImpl() { | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return Messages.EventType_SecurityScanCompleted_DisplayName(); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/org/jenkinsci/plugins/registry/notification/events/impl/TagDeleted.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,40 @@ | ||
package org.jenkinsci.plugins.registry.notification.events.impl; | ||
|
||
import hudson.EnvVars; | ||
import hudson.Extension; | ||
import hudson.model.Run; | ||
import org.jenkinsci.plugins.registry.notification.Messages; | ||
import org.jenkinsci.plugins.registry.notification.events.EventType; | ||
import org.jenkinsci.plugins.registry.notification.events.EventTypeDescriptor; | ||
import org.jenkinsci.plugins.registry.notification.webhook.WebHookPayload; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class TagDeleted extends EventType { | ||
|
||
@DataBoundConstructor | ||
public TagDeleted() { | ||
} | ||
|
||
@Override | ||
public boolean accepts(WebHookPayload payload) { | ||
return false; //TODO | ||
} | ||
|
||
@Override | ||
public void buildEnvironment(@Nonnull Run r, @Nonnull EnvVars envs) { | ||
envs.put(EventTypeDescriptor.ENVIRONMENT_KEY, "TAG_DELETED"); //TODO perhaps something more appropriate? | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends EventTypeDescriptor { | ||
public DescriptorImpl() { | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return Messages.EventType_TagDeleted_DisplayName(); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/org/jenkinsci/plugins/registry/notification/events/impl/TagPushed.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,40 @@ | ||
package org.jenkinsci.plugins.registry.notification.events.impl; | ||
|
||
import hudson.EnvVars; | ||
import hudson.Extension; | ||
import hudson.model.Run; | ||
import org.jenkinsci.plugins.registry.notification.Messages; | ||
import org.jenkinsci.plugins.registry.notification.events.EventType; | ||
import org.jenkinsci.plugins.registry.notification.events.EventTypeDescriptor; | ||
import org.jenkinsci.plugins.registry.notification.webhook.WebHookPayload; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class TagPushed extends EventType { | ||
|
||
@DataBoundConstructor | ||
public TagPushed() { | ||
} | ||
|
||
@Override | ||
public boolean accepts(WebHookPayload payload) { | ||
return false; //TODO | ||
} | ||
|
||
@Override | ||
public void buildEnvironment(@Nonnull Run r, @Nonnull EnvVars envs) { | ||
envs.put(EventTypeDescriptor.ENVIRONMENT_KEY, "TAG_PUSHED"); //TODO perhaps something more appropriate? | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends EventTypeDescriptor { | ||
public DescriptorImpl() { | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return Messages.EventType_TagPushed_DisplayName(); | ||
} | ||
} | ||
} |
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