【问题标题】:What is the best way to create git tags from Azure Pipelines?从 Azure Pipelines 创建 git 标签的最佳方法是什么?
【发布时间】:2021-12-29 20:07:48
【问题描述】:

我目前正在使用扩展来创建 git 标签,我的问题是我使用 Azure 平台添加变量而不是 yaml 文件。

- task: GitTag@6
          displayName: 'Creating Git Tag'
          inputs:
            workingdir: '$(SYSTEM.DEFAULTWORKINGDIRECTORY)'
            git: '$(Major).$(Minor).$(Patch)'

变量是:

Name:
Major
Value:
1

Name:
Minor
Value:
0

Name:
Patch
Value:
$[counter(format('{0}.{1}', variables['Major'], variables['Minor']), 0)]

当前输出如下:

1.0.0

我的问题是:如何在 yaml 文件中将补丁声明为变量。我尝试添加以下变量:

- name: Major
  value: 1
- name: Minor
  value: 0
- name: patch
  value: echo "##vso$[counter(format('{0}.{1}', variables['Major'], variables['Minor']), 0)]"

现在我的新输出是:


1.0.$[counter(format('{0}.{1}', variables['Major'], variables['Minor'])

有谁知道如何在 yaml 文件中添加脚本作为变量?

【问题讨论】:

    标签: powershell automation scripting azure-pipelines pipeline


    【解决方案1】:

    您也许可以使用 Run Inline Powershell Azure Pipelines 任务,如下所示:

    - task: InlinePowershell@1
      inputs:
        Script: |
          $foo = 'bar'
          Write-Output "##vso[task.setvariable variable=foo;]$foo"
    

    【讨论】:

    • 我仍然遇到同样的问题
    猜你喜欢
    • 1970-01-01
    • 2014-12-10
    • 2020-03-03
    • 2017-08-06
    • 2022-01-05
    • 2017-04-13
    • 1970-01-01
    • 2013-01-12
    • 1970-01-01
    相关资源
    最近更新 更多