1
votes

This might be a super loaded task and I'm hoping I am asking the right question. But basically, has anyone experienced this permissions issue before and know a way around it? If I remove the 2 stages/jobs entirely and just run it all under 1 stage/job, it works perfectly with no issues. I was just trying to see how I could separate tasks (there are more tasks than what is shown below, but I simplified it). If I run the all the tasks within 1 stage or 1 job, it works and I don't get any errors. However, if I try to break out the steps into stages or jobs, it fails.

I have 2 stages (can be broken up by jobs as well if needed) that I want to get setup. The 1st stage runs a yarn install. (excuse spacing, the spacing is correct on my pipeline, but might have shifted in copying it here).

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'

The 2nd stage needs to receive the install of the previous agent's install of yarn. I have tried to use the PublishPipelineArtifact & DownloadPipelineArtifact commands and I do in fact see that the 2nd Stage's Agent does have the yarn install already completed (tested it by trying to install it again, and the result showed it was already installed), however, running a "yarn run build:" fails due to permissions issue (task is not shown for shortening purposes). If I do break the tasks up into 2 stages/jobs, then i get the following error when trying to test my yarn build.

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.

Any thoughts are appreciated!! Let me know if I need to clarify anything.

1

1 Answers

0
votes

Turns out I was utilizing the pipeline artifact publish/download correctly, and was failing my pipeline due to a yaml/react issue. I will now ask for 10,000 pardons on this question as the answer was to add 1 task (shown below) after my download in the 2nd stage.

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