change file parameter dynamically

22 views Asked by At

I have a pipeline that has a file parameter configured in it. when we build the pipeline we provide the parameter and all is well.

However, I have now been tasked with the issue of dynamically replacing (after the pipeline has already been started) the value of the file parameter.

for example, lets say the pipeline was triggered with file A assigned to the file parameter, then as the pipeline continues, in one of the later stages I need to assign file B (which already exists in my nodes workspace) to the file parameter.

I haven't found any way to this on the internet, any help would be appreciated.

I tried looking online and using ChatGPT but I haven't had any luck :(

1

There are 1 answers

0
Iterokun On

Parameters as such are unmodifiable (and it's a bad idea to modify them even if you are allowed to), but nothing is stopping you from using a variable:

// When the pipeline starts
script {
    effectiveFileName = params.fileName
}
...
// Later when you need to change the value
script {
    effectiveFileName = 'B'
}