File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ # Environment Variable Lifetimes
2+
3+ # 1. Session ($env:VARIABLE)
4+ $env: MY_VAR = " value1"
5+ Write-Host $env: MY_VAR
6+
7+ # 1.1. Environment variable with dynamic key
8+ $key = " MY_VAR"
9+ Set-Item " env:$key " " value2"
10+
11+ # 2. Process-Level Inheritance
12+ # when you set an environment variable in PowerShell,
13+ # it is inherited by child processes (like dotnet run, git, or other spawned applications).
14+
15+ # 3. Permanent Environment Variables (Registry)
16+ [System.Environment ]::SetEnvironmentVariable(" MY_VAR" , " value1" , " User" )
17+ Write-Host $env: MY_VAR
18+
19+ # 4. Environment Variables in GitHubs Actions
20+ # Environment variables set during one step are not automatically available in subsequent steps in GitHub Actions.
21+ # To persist environment variables between steps, you need to explicitly use the GITHUB_ENV file.
22+ $value = " value1"
23+ echo " $key =$value " >> $env: GITHUB_ENV
You can’t perform that action at this time.
0 commit comments