简体   繁体   中英

azure devops pipeline script is giving bash error

Azure devops pipeline script is giving error Bash exited with code '127'.

YAML script is not working for devops pipeline.

    trigger:
      - master

   pool:
      vmImage: 'Ubuntu-16.04'

   steps:
      - task: NodeTool@0
   inputs:
       versionSpec: '10.x'
       displayName: 'Install Node.js'

   - script: |
        start
        displayName: 'npm install and build'

package.json there is script "start". After running this script it is showing error Bash exited with code '127'.

Your YAML is invalid for multiple reasons. I first of all recommend that you not indent the root level (semantically it makes no difference). If you do that you'll more easily see that the first key ( trigger ) is indented more than the second key ( pool ):

 trigger:
   - master

pool:
   vmImage: 'Ubuntu-16.04'

steps:
   - task: NodeTool@0

Then at the end of the file you have sequence entry indicator ( - at the same level as a value for the key inputs but that key already has a mapping as value (the one with keys versionSpec and displayName ), and you cannot have a node in YAML that has both sequence and mapping elements. It is not obvious though how to fix this.

Not fatal, but a recommendation anyway: you should indent the sequences with the same a mount of whitespace. The sequence that is the value for trigger is indented 4 positions for the entry with an offset for the sequence-entry indicator of 2. For value of steps this is 5 resp. 3. It pays of to keep this consistent, and if you have a hard time doing that, there are tools available (both installable and online) that do that for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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