[英]How to view or get the service connection id in Azure DevOps
有没有办法查看或获取我在 Azure DevOps 中创建的服务连接的服务连接 ID?
我在我创建的 yaml 管道中需要它们。 例如,您在下面看到的 dockerRegistryServiceConnection 在 docker@02 任务中用于设置 containerRegistry,如果您在下面看到。
variables:
- name: vmImageName
value: ubuntu-latest
# Container registry service connection established during pipeline creation
- name: dockerRegistryServiceConnection
value: 'd072f8f7-fag1-asdf-467e-7fd5jfr5gjh6' # This is not a true id
- name: imageRepository
value: 'globoticket.services.discount'
- name: containerRegistry
value: 'reacrtrialsregistry.azurecr.io'
- name: dockerfileFolderPath
value: 'src/Services/GloboTicket.Services.Discount'
- name: tag
value: '$(Build.BuildId)'
name: $(date:yyyyMMdd)$(rev:.r)
stages:
- stage: Build
jobs:
- job: buildWebApp
displayName: Build Release pipeline for Discount Service on Master branch
pool:
vmImage: $(vmImageName)
steps:
- checkout: self
- task: Docker@2
displayName: Build the image
inputs:
command: build
repository: $(imageRepository)
dockerfile: $(dockerfileFolderPath)/Dockerfile
buildContext: .
tags: |
$(tag)
- script: |
sudo docker tag $(imageRepository):$(tag) $(containerRegistry)/$(imageRepository):$(tag)
displayName: 'Tag container image before push'
- task: Docker@2
displayName: Push an tagged image to container registry
inputs:
command: push
repository: $(imageRepository)
dockerfile: $(dockerfileFolderPath)/Dockerfile
buildContext: .
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
- stage: DeployToDev
displayName: Deploy to Dev Env
jobs:
- deployment:
pool:
vmImage: ubuntu-latest
environment: Dev
strategy:
runOnce:
deploy:
steps:
- script: |
echo Any deploy stage starts here.
displayName: 'Command Line Script to write out some messages'
根据文档,docker 任务的containerRegistry
输入的输入是服务连接的名称,而不是 id:
容器注册表(可选):Docker 注册表服务连接的名称
如果还需要ID,可以点击Project Settings -> Service Connections
下列表中的服务连接,从url中的resourceId参数中获取服务连接ID:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.