0

I need to update my build param in declarative pipeline script, I tried:

pipeline {
    stages {
        stage {
            steps {
                script {
                    def reporter = build.buildVariableResolver.resolve("reporter")
                    if (reporter != null) {
                        reporter = reporter.tokenize(',').find {item -> item.contains('displayName')}.tokenize('=')[1]
                    } else {
                      reporter = ""
                    }
                    def reporterParameter = new StringParameterValue("reporter", "\${reporter}")
                    build.addOrReplaceAction(new ParametersAction(reporterParameter))
                }
            }
        }
    }
}

but I get error hudson.remoting.ProxyException: groovy.lang.MissingPropertyException: No such property: build for class: WorkflowScript How can I run this groovy script in declarative pipeline or upadate my build params in another way (but declaratively)

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Kucharsky
  • 201
  • 3
  • 16
  • Did you check this : https://stackoverflow.com/a/19564602/7953086 I think you are using the Jenkins v1.x syntax. – fmdaboville Sep 02 '21 at 13:32
  • Sorry, I can't see the answer to my question there. I think this is problem I'm trying execute groovy script in declarative section and there cannnot be found specific classes and their methods – Kucharsky Sep 02 '21 at 13:47
  • But what you want to achieve is to set a parameter on the fly during a step ? I think you are using an old syntax, maybe you can perform it using this : https://stackoverflow.com/a/57411391/7953086 – fmdaboville Sep 02 '21 at 14:42

0 Answers0