Reputation: 44
I have some logic to find calculate variable in CI pipeline and want this variable to access in CD pipeline. is there any way. Is setting variable like below, would that be accessible in CD ?
echo "##vso[task.setvariable variable=CALC;isOutput=true]${VALUE}"
I don't want to use the variable group here to set and access. Any other way than variable group ?
Upvotes: 0
Views: 1104
Reputation: 2206
In your CI pipeline, you could put your variable into a .txt file and publish the .txt file to Artifacts
trigger:
- none
pool:
vmImage: ubuntu-latest
parameters:
- name: projectName
displayName: project name?
type: string
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$variable = '${{parameters.projectName}}'
$variable | Out-file $(Build.ArtifactStagingDirectory)\projectname.txt
Get-Content $(Build.ArtifactStagingDirectory)\projectname.txt
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: Container
I set 0615 as variable to pass
In your CD pipeline, Download Build Artifacts and get the variable from the .txt file
$myValue = Get-Content $(System.ArtifactsDirectory)/drop/projectname.txt;
Write-Host $myValue
#Write-Host "##vso[task.setvariable variable=ProjectName]($myVaule)";
Upvotes: 2