简体   繁体   English

从 Azure 管道创建 git 标签的最佳方法是什么?

[英]What is the best way to create git tags from Azure Pipelines?

I'm currently using an extension to create the git tag, my problem is that I'm using the Azure Platform to add the variables instead of the yaml file.我目前正在使用扩展来创建 git 标签,我的问题是我使用 Azure 平台添加变量而不是 yaml 文件。

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

The Variables are:变量是:

Name:
Major
Value:
1

Name:
Minor
Value:
0

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

The current output is the following:当前的output如下:

1.0.0

My question would be: How can I declare the Patch as a variable in the yaml file.我的问题是:如何在 yaml 文件中将补丁声明为变量。 I tried to add the following variables:我尝试添加以下变量:

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

Now my new output is:现在我的新 output 是:


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

Does anyone knows how can I add a script as a variable inside of the yaml file?有谁知道如何在 yaml 文件中添加脚本作为变量?

You might be able to use the Run Inline Powershell Azure Pipelines task, like so:您也许可以使用Run Inline Powershell Azure Pipelines 任务,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Azure Devops Pipelines 中读取 Git 标签? - Reading Git Tags in Azure Devops Pipelines? 在 git 中从远程创建功能分支的最佳方法是什么? - what's the best way to create a feature branch from remote in git? 从 bitbucket 管道中推送 git 标签? - Pushing git tags from bitbucket pipelines? 从 Azure 管道合并 PowerShell 中的 git 分支 - Merge git branches in PowerShell from Azure Pipelines git hooks和Azure DevOps管道有什么区别? - What is the difference between git hooks and Azure DevOps pipelines? 从Bitbucket推送标签时,Azure管道CI不会触发 - Azure Pipelines CI not triggering when pushing tags from Bitbucket 标签触发器在 azure 管道中不起作用 - Tags trigger not working in azure pipelines 使用git修改master历史记录而不影响标签的最佳方法是什么? - What's the best way to use git to modify the history of master without affecting tags? 从git仓库中提取树的最佳方法是什么? - What's the best way to extract a tree from a git repository? Git / Bitbucket管道-是什么导致标签根据我推送到哪个分支而出现不同的外观? - Git/Bitbucket pipelines - What causes tags to appear different depending on what branch I push to?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM