I have a jenkinsfile, where I am setting a parameter and wants to use it in another powershell script.
Here is my jenkinsfile
parameters {
choice( name: 'DeploymentEnvironment',choices: "None\nDev\nQA\nProd",description: 'Deployment Choice')
}
stage('Publishing to S3') {
steps {
withCredentials() {
echo "${params.DeploymentEnvironment}"
powershell(". '.\\packages.ps1' ${params.DeploymentEnvironment}")
}
}
}
echo "${params.DeploymentEnvironment}" = QA
My packages.ps1 script
...
Write-Output $DeploymentEnvironment
Write-Output $env.DeploymentEnvironment
Write-Output $env:DeploymentEnvironment
Write-Output ($params.DeploymentEnvironment)
...
I am unable to get DeploymentEnvironment=QA here in packages.ps1. Above every Write-Output command is printing nothing.
How can I pass and use DeploymentEnvironment variable declared in Jenkinsfile in my packages.ps1 script.
Thanks.