To get around this, I added code to check the JENKINS_URL environment variable. If a user on a test Jenkins instance tries to deploy to production, the script will immediately stop the deploy.
$env is a reserved variable by PowerShell that imports the JENKINS_URL variable without passing it to the script.
# Check Jenkins URL $JENKINS_URL = $env:JENKINS_URL if (($rngenv -eq "prod") -and ($JENKINS_URL -ne "http://jenkinswin.fbfs.com/jenkins")) { Write-Host "Production deploys must be done from a production Jenkins instance" Exit}
No comments:
Post a Comment