如果你在下面看到我的 Yaml,我有 $(Build.SourcesDirectory) 有我正在下载和复制到 Azure Blob 的工件。在下一阶段,我想使用 $(Build.SourcesDirectory) 内容,但如果我在下一阶段调用 $(Build.SourcesDirectory) ,我将一无所获。为什么会发生这种情况,我该如何解决?
- task: PublishPipelineArtifact@1
displayName: 'Publish PS'
inputs:
targetPath: $(Build.ArtifactStagingDirectory)\flow_ps
artifactName: 'Flow_Tools_PS'
- task: DownloadPipelineArtifact@2
displayName: Download Flow CodeGen
inputs:
artifact: 'Flow_Tools_PS'
path: '$(Build.SourcesDirectory)/Flow_Tools_PS'
- task: AzureFileCopy@2
displayName: 'Publish Flow_Tools_PS to Blob'
inputs:
SourcePath: '$(Build.SourcesDirectory)/Flow_Tools_PS'
azureSubscription: 'Azure CICD'
Destination: AzureBlob
storage: '$(BlobStorageAccount)'
ContainerName: '$(BlobContainer)'
BlobPrefix: '$(BlobPrefix)/$(DeploymentVersion)/Flow_Tools_PS'
AdditionalArgumentsForBlobCopy: '/V /S'
outputStorageUri: BlobUri
outputStorageContainerSasToken: BlobSASToken
- stage: PublishFlowNotebooks
dependsOn: Flow
jobs:
- job: DevOpsScripts
pool:
vmImage: 'windows-latest'
environment: 'Flow'
steps:
- checkout: DevOpsScripts
- powershell: |
Get-ChildItem $(Build.SourcesDirectory) -Recurse
name: DebugCheckout
displayName: Debug script checkout
- task: DownloadPipelineArtifact@2
inputs:
buildVersionToDownload: 'latest'
targetPath: '$(Pipeline.Workspace)'
- task: PowerShell@2
displayName: 'PowerShell Script'
inputs:
targetType: filePath
filePath: '$(System.DefaultWorkingDirectory)/ReleaseNoteScripts/UploadWithReleaseNotes.ps1'
答案 0 :(得分:1)
如果您想在作业之间共享某些目录,您应该发布该目录的内容:
steps:
- publish: $(Build.SourcesDirectory)
artifact: Flow
然后在下一个工作中下载这个工件:
steps:
- download: current
artifact: Flow
请注意
<块引用>默认情况下,文件下载到 $(Pipeline.Workspace)/。如果未指定工件名称,将为每个下载的工件创建一个子目录。
您可以阅读有关此 here 的更多信息。
如果你想checkout multiple repositories,这是可能的
resources:
repositories:
- repository: MyGitHubRepo # The name used to reference this repository in the checkout step
type: github
endpoint: MyGitHubServiceConnection
name: MyGitHubOrgOrUser/MyGitHubRepo
- repository: MyBitbucketRepo
type: bitbucket
endpoint: MyBitbucketServiceConnection
name: MyBitbucketOrgOrUser/MyBitbucketRepo
- repository: MyAzureReposGitRepository # In a different organization
endpoint: MyAzureReposGitServiceConnection
type: git
name: OtherProject/MyAzureReposGitRepo
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
- checkout: MyGitHubRepo
- checkout: MyBitbucketRepo
- checkout: MyAzureReposGitRepository
- script: dir $(Build.SourcesDirectory)