Forked from jimCresswell/jenkinsParsingForGithubPayload
Created
March 8, 2023 09:47
-
-
Save saquibtmf/a1c860e76627365efdb44d6540ffeb36 to your computer and use it in GitHub Desktop.
Jenkins script in Groovy to parse a Github web hook payload for the commit that triggered the pull request that triggered the service hook ... and then set that as a build variable that can be used in further Jenkins scripts or parameterised jobs. See http://chloky.com/github-pull-req-webhook/ and https://gist.github.com/bjhess/2726012 for setti…
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
import hudson.model.* | |
def payloadString = build.buildVariableResolver.resolve("payload") | |
payloadObject = new groovy.json.JsonSlurper().parseText(payloadString) | |
targetCommit = payloadObject.pull_request.head.sha | |
build.addAction(new ParametersAction(new StringParameterValue('targetCommit', targetCommit))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment