-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exposed the following keys from the JSON to environment variables: - GOGS_REF - GOGS_AFTER
- Loading branch information
Showing
7 changed files
with
323 additions
and
175 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,6 @@ release.properties | |
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties | ||
|
||
# IntelliJ | ||
.idea/ |
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,36 @@ | ||
package org.jenkinsci.plugins.gogs; | ||
|
||
import hudson.EnvVars; | ||
import hudson.model.AbstractBuild; | ||
import hudson.model.EnvironmentContributingAction; | ||
import hudson.model.InvisibleAction; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class GogsPayload extends InvisibleAction implements EnvironmentContributingAction { | ||
private Map<String,String> payload = new HashMap<String, String>(); | ||
|
||
public GogsPayload(Map<String, String> payload) { | ||
this.payload = payload; | ||
} | ||
|
||
@Nonnull | ||
public Map<String, String> getPayload() { | ||
return payload; | ||
} | ||
|
||
@Override | ||
public void buildEnvVars(AbstractBuild<?, ?> abstractBuild, EnvVars envVars) { | ||
final Map<String, String> payload = getPayload(); | ||
LOGGER.log(Level.FINEST, "Injecting GOGS_PAYLOAD: {0}", payload); | ||
for(String key: payload.keySet()) { | ||
envVars.put("GOGS_"+key.toUpperCase(), this.payload.get(key)); | ||
} | ||
} | ||
|
||
private static final Logger LOGGER = Logger.getLogger(GogsPayload.class.getName()); | ||
} |
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
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,62 @@ | ||
package org.jenkinsci.plugins.gogs; | ||
|
||
|
||
import hudson.Extension; | ||
import hudson.model.Hudson; | ||
import hudson.model.Item; | ||
import hudson.model.Job; | ||
import hudson.triggers.Trigger; | ||
import hudson.triggers.TriggerDescriptor; | ||
import hudson.util.SequentialExecutionQueue; | ||
import jenkins.model.ParameterizedJobMixIn; | ||
import jenkins.triggers.SCMTriggerItem; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import java.util.logging.Logger; | ||
|
||
|
||
public class GogsTrigger extends Trigger<Job<?,?>> { | ||
|
||
@DataBoundConstructor | ||
public GogsTrigger() { | ||
} | ||
|
||
@Deprecated | ||
public void onPost(String triggeredByUser) { | ||
onPost(triggeredByUser, ""); | ||
} | ||
|
||
public void onPost(String triggeredByUser, final String payload) { | ||
final String pushBy = triggeredByUser; | ||
getDescriptor().queue.execute(new Runnable() { | ||
|
||
@Override | ||
public void run() { | ||
|
||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public DescriptorImpl getDescriptor() { | ||
return (DescriptorImpl)super.getDescriptor(); | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends TriggerDescriptor { | ||
private transient final SequentialExecutionQueue queue = new SequentialExecutionQueue(Hudson.MasterComputer.threadPoolForRemoting); | ||
|
||
@Override | ||
public boolean isApplicable(Item item) { | ||
return item instanceof Job && SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(item) != null | ||
&& item instanceof ParameterizedJobMixIn.ParameterizedJob; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "Build when a change is pushed to Gogs"; | ||
} | ||
} | ||
|
||
private static final Logger LOGGER = Logger.getLogger(GogsTrigger.class.getName()); | ||
} |
Oops, something went wrong.