Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from fbelzunc/JENKINS-32372
[FIXED JENKINS-32372] Inject the payload into the build
- Loading branch information
Showing
5 changed files
with
60 additions
and
7 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/main/java/com/cloudbees/jenkins/plugins/BitBucketPayload.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,37 @@ | ||
package com.cloudbees.jenkins.plugins; | ||
|
||
import hudson.EnvVars; | ||
import hudson.model.AbstractBuild; | ||
import hudson.model.EnvironmentContributingAction; | ||
import hudson.model.InvisibleAction; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
/** | ||
* Inject the payload received by BitBucket into the build through $BITBUCKET_PAYLOAD so it can be processed | ||
* @since January 9, 2016 | ||
* @version 1.1.5 | ||
*/ | ||
public class BitBucketPayload extends InvisibleAction implements EnvironmentContributingAction { | ||
private final @Nonnull String payload; | ||
|
||
public BitBucketPayload(@Nonnull String payload) { | ||
this.payload = payload; | ||
} | ||
|
||
@Nonnull | ||
public String getPayload() { | ||
return payload; | ||
} | ||
|
||
@Override | ||
public void buildEnvVars(AbstractBuild<?, ?> abstractBuild, EnvVars envVars) { | ||
final String payload = getPayload(); | ||
LOGGER.log(Level.FINEST, "Injecting BITBUCKET_PAYLOAD: {0}", payload); | ||
envVars.put("BITBUCKET_PAYLOAD", payload); | ||
} | ||
|
||
private static final Logger LOGGER = Logger.getLogger(BitBucketPayload.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
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