Permission denied while executing files between stages in Azure

Viewed 38

I have a sample project with a simple C file( hello world program). I am trying to get familiar with artifacts and hence I have started with pipeline artifacts. The pipeline has 2 stages, build and Test. In the build stage, I compile the C file, then publish the artifact. In the test stage, I run the object file.

trigger:
  branches:
    include:
      - '*'
pool:
  vmImage: ubuntu-latest

stages:
  - stage: build
    jobs:
      - job: buildjob
        steps:
          - script: |
              echo "building the test.c file"
              gcc test.c -o test
              echo "build completed"
        
          - task: PublishPipelineArtifact@1
            inputs:
              targetPath: $(System.DefaultWorkingDirectory)
              artifactName: Test
  - stage: test
    jobs:    
      - job: testJob
        steps:
          - download: current
            artifact: Test
          - script: |
              cd Test
              echo "Running the object file"
              ./test
              echo "job finished"

Error: Error

I can see that the artifacts have been published: Artifacts

Concerns: What do I have to do to get the object file running`? Also can i just pass the object file alone to the artifact? How?

UPDATE I have managed to find the correct path to the artifact folder. But I cannot seem to execute the file. It shows permission denied

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
  branches:
    include:
      - '*'
pool:
  vmImage: ubuntu-latest

stages:
  - stage: build
    jobs:
      - job: buildjob
        steps:
          - script: |
              echo "building the test.c file"
              gcc test.c -o test
              echo "build completed"
        
          - task: PublishPipelineArtifact@1
            inputs:
              targetPath: $(System.DefaultWorkingDirectory)
              artifactName: Test
  - stage: test
    jobs:    
      - job: testJob
        steps:
          - download: current
            artifact: Test
          - script: |
              echo "Running the object file"
              cd  $(Pipeline.Workspace)/Test
              ./test
              echo "job finished"

New Error: Permission denied error

0 Answers
Related