How can you edit assembly parameters in a Jenkins workflow?

I know that you can access build options directly in Jenkins Workflow. I have a BRANCH_REVISION parameter that I need to update so that the xml api call displays a new value instead of the original value. This is what I did in a non-workflow script using the following groovy snippet:

def currentParamActions = build.getAction(ParametersAction.class)
def currentParams = currentParamActions.getParameters()

currentParams.each() {
    if ( it.name.equals("BRANCH_REVISION") ) {
        newParams.add( new StringParameterValue("BRANCH_REVISION", newRevision ) )
    }
    else {
        newParams.add( it )
    }
}

build.actions.remove(currentParamActions)
new_param_actions = currentParamActions.createUpdated(newParams)
build.actions.add(new_param_actions)

However, this does not seem to work in Workflow because the assembly object is not available. Thanks in advance for your help!

+4
source share
1 answer

. < > → → ☑ Snippet → → : currentBuild:

currentBuild . , build.

currentBuild.build() build org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper, currentBuild.

+4

Source: https://habr.com/ru/post/1613977/


All Articles