Hi, I have two stages, on different agents, that both need to access parameters from a yaml file. I am reading the file twice. How can I change the scope of yaml_params so that I only need to read the file once?
pipeline {
agent { label "agent_1" }
parameters { string defaultValue: '', description: '', name: 'yaml_path', trim: true }
stages {
stage('run') {
steps {
script {
def yaml_params = readYaml file: params.yaml_path // Read the YAML file
<snip>
}
}
}
stage('zip') {
agent { label "agent_2" }
steps {
script {
def yaml_params = readYaml file: params.yaml_path // Read the YAML file
<snip>
}
}
}
}
}