Azure DevOps Pipeline Yml/Yaml阶段到阶段工件/权限共享



这可能是一个超负荷的任务,我希望我问的问题是正确的。但基本上,有人以前经历过这种权限问题并知道解决方法吗?如果我完全删除了两个阶段/作业,只在一个阶段/工作下运行,它就可以完美地工作,没有任何问题。我只是想看看如何分离任务(任务比下面显示的要多,但我简化了它(。如果我在一个阶段或一个作业中运行所有任务,就会工作,并且不会出现任何错误。然而,如果我试图将这些步骤分解为阶段或工作,它就会失败。

我有两个阶段(如果需要,也可以按工作划分(,我想设置。第一阶段运行纱线安装。(请原谅间距,我的管道上的间距是正确的,但在复制到这里时可能发生了偏移(。

stages:
- stage: BUILD
displayName: 'Build'
jobs:
- job: Build
displayName: "Build!!!"
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
- script: |
yarn install
displayName: 'Yarn install'
workingDirectory: '$(System.DefaultWorkingDirectory)/location'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Pipeline.Workspace)'
artifact: 'rememberme'
publishLocation: 'pipeline'
- stage: DEPLOY
displayName: 'Deploy'
jobs:
- job: Deploy
displayName: "Deploy!!!"
pool:
vmImage: 'ubuntu-latest'
steps:
- task: DownloadPipelineArtifact@0
inputs:
buildType: 'current'
artifactName: 'rememberme'
targetPath: '$(Pipeline.Workspace)'
- task: CopyFiles@2
displayName: Deploy my env
inputs:
sourceFolder: $(System.DefaultWorkingDirectory)/location/deploy 
contents: '**' 
targetFolder: '$(Build.ArtifactStagingDirectory)/dev_space'

第二阶段需要接收先前代理的纱线安装。我尝试过使用PublishPipelineArtifact&DownloadPipelineArtifact命令,事实上我确实看到第二阶段的代理确实已经完成了yarn安装(通过尝试再次安装来测试它,结果显示它已经安装(,然而;纱线运行构造:";由于权限问题而失败(为了缩短时间,未显示任务(。如果我确实将任务分解为2个阶段/作业,那么在尝试测试我的纱线构建时会出现以下错误。

yarn run v1.22.10
$ env-cmd -f .env.test react-scripts build
/bin/sh: 1: env-cmd: Permission denied
error Command failed with exit code 126.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

感谢您的任何想法!!如果我需要澄清什么,请告诉我。

事实证明,我正确地使用了管道工件发布/下载,并且由于yaml/react问题导致管道失败。我现在将请求10000次赦免这个问题,因为答案是在第二阶段下载后添加1个任务(如下所示(。

- script: |
yarn add react-scripts
displayName: 'React Scripts'
workingDirectory: '$(Pipeline.Workspace)/location'

最新更新