繁体   English   中英

如何从 Yaml 管道中的存储库中读取脚本文件 azure Devops

[英]How to read a script file from a repo in Yaml Pipeline in azure Devops

我有一个存储库,其中有一个 powershell(.ps1) 文件,我想在 Yaml 管道的阶段之一中调用该文件。 我正在尝试以下方式,但我得到的错误是“[error]ENOENT: no such file or directory, stat '/home/vsts/work/1/s/_DevOpsScripts/ReleaseNoteScripts/abc.ps1'”

想知道调用 powershell 脚本的正确方法是什么。

这是我现在正在做的事情

name: $(SourceBranchName)_$(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)
trigger:
  - master

resources:
  repositories:
  - repository: DevOpsScripts
    type: git
    name: XeThru/DevOpsScripts
    trigger:
      branches:
        include:
          - master


- stage: PublishSignalFlowNotebooks
    dependsOn: SignalFlow
    jobs:
      - job: SignalFlow_ReleaseNoteBook    
        steps:
          - checkout: DevOpsScripts
          - task: PowerShell@2
            displayName: 'PowerShell Script'
            inputs:
                targetType: filePath
                filePath: $(System.DefaultWorkingDirectory)/_DevOpsScripts/ReleaseNoteScripts/abc.ps1
                arguments: '-WId $(NoteBookArtifactDirectory) -ClientID $(clientId) -ClientSecret $(clientSecret) -RDname $(Release.DefinitionName) -RName $(Release.ReleaseName) -RReqFor $(Release.RequestedFor) -RRId $(Release.ReleaseId) -NbId $(NotebookId) -SPid $(SharePointSiteID) -LibId $(LibraryID) -AzDevToken $(AzureDevOpsPersonalAccessToken)' 

在调试我得到这个:

Directory: D:\a\1\s


Mode                LastWriteTime         Length Name                                                                  
----                -------------         ------ ----                                                                  
d-----        3/11/2021   6:03 PM                ReleaseNoteScripts                                                    
-a----        3/11/2021   6:03 PM           1319 README.md                                                             


    Directory: D:\a\1\s\ReleaseNoteScripts


Mode                LastWriteTime         Length Name                                                                  
----                -------------         ------ ----                                                                  
-a----        3/11/2021   6:03 PM           5341 UploadInSharePoint.ps1                                                
-a----        3/11/2021   6:03 PM          13779 abc.ps1 

checkout任务之后、 PowerShell@2任务之前添加以下步骤以调试实际结帐位置:

- pwsh: |
    Get-ChildItem $(System.DefaultWorkingDirectory) -Recurse
  name: DebugCheckout
  displayName: Debug script checkout

这可能会产生大量的 output,但是一旦签出,它应该让您了解脚本的实际位置。 我猜它可能很简单,就像在路径中不需要_一样。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM