有什么方法可以将变量从CI传递到CD管道

发布于 2025-02-08 03:22:50 字数 204 浏览 2 评论 0 原文

我有一些逻辑可以在CI管道中找到计算变量,并希望此变量在CD管道中访问。有什么办法。设置变量是否如下,在CD中可以访问吗?

  echo "##vso[task.setvariable variable=CALC;isOutput=true]${VALUE}"

我不想在此处使用变量组来设置和访问。除了可变组以外,还有其他方法吗?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼中杀气 2025-02-15 03:22:51

在您的CI管道中,您可以将变量放入.txt文件中,然后将.txt文件发布到工件中,

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

我将0615设置为变量,以通过

“在此处输入映像说明”

在您的CD管道中,下载构建伪像并获取变量来自.txt文件

“在此处输入图像描述”

”在此处输入映像说明“

$myValue = Get-Content $(System.ArtifactsDirectory)/drop/projectname.txt;
Write-Host $myValue

#Write-Host "##vso[task.setvariable variable=ProjectName]($myVaule)";

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

enter image description here

In your CD pipeline, Download Build Artifacts and get the variable from the .txt file

enter image description here

enter image description here

$myValue = Get-Content $(System.ArtifactsDirectory)/drop/projectname.txt;
Write-Host $myValue

#Write-Host "##vso[task.setvariable variable=ProjectName]($myVaule)";

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文