An environment variable supplies a named value from the process environment to an application or script. In Jenkins, it provides the parameter-passing mechanism when command-line parameters are unavailable. section 3.2.4
PowerShell reads Jenkins variables through the $env: scope. Replacing a script's parameter block with values such as $env:logpath preserves existing variable usage while adapting the script to scheduled execution. section 3.2.4
Use environment variables to:
- Pass configurable paths, prefixes, and retention values into a scheduled Jenkins job. section 3.2.4
- Supply Jenkins-managed credentials and secret text at execution time. section 4.4.2
- Reconstruct PowerShell SecureString or PSCredential objects when Jenkins provides secret values as ordinary strings. section 4.4.2
Jenkins-driven log cleanup
A PowerShell cleanup script can assign $LogPath, $ZipPath, $ZipPrefix, and $NumberOfDays from $env:logpath, $env:zippath, $env:zipprefix, and $env:numberofdays. Jenkins then supplies matching string parameters and runs the job on a schedule. section 3.2.4
$LogPath = $env:logpath $ZipPath = $env:zippath $ZipPrefix = $env:zipprefix $NumberOfDays = $env:numberofdays
This listing shows the compact PowerShell pattern for mapping Jenkins environment variables to the script's existing parameter names. section 3.2.4


















