Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Permission issue while executing downloaded pipeline artifact in Azure devops CI

I am using multiple stages in my pipeline to understand the different paradigms.
To share files between stages, I made use of pipeline artifacts. Building in one stage and testing the result in another.
To support this, I have a simple C file, which prints hello.

My pipeline

trigger:
- main

pool:
  vmImage: ubuntu-latest

stages:
- stage: Build
    jobs:
      - job: BuildJob
        steps:
          - script: |
              echo compiling the c file
              gcc hello.c -o hello
              echo finished compiling
              echo "publishing the contents"
          - publish: $(System.DefaultWorkingDirectory)
            artifact: myobj

  - stage: Test
    jobs:
      - job: Testing
        steps:
         - download: current
           artifact: myobj
         - script: |
              cd  $(Pipeline.Workspace)/myobj
              ./hello

I get following error message :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

/home/vsts/work/_temp/3ba036fd-22vm0-4e54-b5a4-3ce3ce00f7e6.sh: line 4: ./hello: Permission denied
##[error]Bash exited with code '126'.

Is there anything conceptual that I am missing? Or in the script?

>Solution :

Restoring the artifact hasn’t restored the executable bit on the build outcome.

Add a script step that does:

chmod +x ./hello

Or add it to your existing script:

         - script: |
              cd  $(Pipeline.Workspace)/myobj
              chmod +x ./hello
              ./hello
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading