I am in need of modifying a Jenkins Pipeline script. This is a snippet. It works down to the Def in the rename. The error I get is
groovy.lang.MissingPropertyException: No such property: newFileName for class: groovy.lang.Binding
I am looking to inject the version number into the filename which is then processed by a homegrown app to move it where it needs to go and some other stuff. I have tried passing the concatenated ${version} into the Upload executable but it then errors as a literal instead of a variable.
Update: I predefine the variable and get a new error
powershell.exe : newFileName : The term 'newFileName' is not recognized as the name of a cmdlet, function, script file, or operable At C:\workspace\workspace\Centurion Dashboard@tmp\durable-eb5db1ae\powershellWrapper.ps1:3 char:1 & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm
- CategoryInfo : NotSpecified: (newFileName : T...e, or >operable :String) [], RemoteException
- FullyQualifiedErrorId : NativeCommandError
Thoughts?
stage('Rename') {
powershell """
rename-item -Path "C:\\Users\\Administrator\\Documents\\Advanced Installer\\Projects\\Proj\\Setup Files\\SetupCenturionDashboard.exe" -NewName "OtherProject-${version}.exe"
def newFileName = "C:\\Users\\Administrator\\Documents\\Advanced Installer\\Projects\\Proj\\Setup Files\\OtherProject-" + ${version} + ".exe"
echo ${newFileName}
"""
}
stage('Upload') {
bat label: 'Upload', script: 'C:\\Static\\BuildHelper\\BuildHelper.exe ${newFileName} "develop" "home" "${version}"'
}