-
-
Save bogdanRada/0c91ff416cbf4dfb24369c3c4b2479c3 to your computer and use it in GitHub Desktop.
Extract parameters from a jenkins previous build (Declarative pipeline example)
This file contains hidden or 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
| #!groovy | |
| pipeline { | |
| agent any | |
| parameters { | |
| string(name: 'CAUSE', defaultValue: 'anonymous', description: 'Build Cause') | |
| } | |
| stages { | |
| stage('Test Previous Build Status') { | |
| steps { | |
| script { | |
| def lastSuccessfulBuildParams = Jenkins.instance.getItem("${env.JOB_NAME}").lastSuccessfulBuild.actions.find{ it instanceof ParametersAction }?.parameters.find{it.name == 'CAUSE'}?.value | |
| echo "${lastSuccessfulBuildParams}" | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment