Build pipeline failed with error 'Error: Npm failed with return code: 254'

Kavitha Lakshmi Angajala 46 Reputation points
2021-03-29T12:33:06.9+00:00

I was trying to develop data factory pipeline using VSO deployments, I have configured my data factory to a 'Azure DevOps Git' repository with following details

Collaboration branch : master
Publish branch : adf_publish
Root folder : /ADF

I have used the following YAML script

# Sample YAML file to validate and export an ARM template into a build artifact  
# Requires a package.json file located in the target repository  
  
trigger:  
- master #collaboration branch  
  
pool:  
  vmImage: 'ubuntu-latest'  
  
steps:  
  
# Installs Node and the npm packages saved in your package.json file in the build  
  
- task: NodeTool@0  
  inputs:  
    versionSpec: '10.x'  
  displayName: 'Install Node.js'  
  
- task: Npm@1  
  inputs:  
    command: 'install'  
    verbose: true  
  displayName: 'Install npm package'  
  
# Validates all of the Data Factory resources in the repository. You'll get the same validation errors as when "Validate All" is selected.  
# Enter the appropriate subscription and name for the source factory.  
  
- task: Npm@1  
  inputs:  
    command: 'custom'  
    workingDir: '$(Build.SourcesDirectory)/ADF'  
    customCommand: 'run build validate $(Build.Repository.LocalPath)/ADF /subscriptions/[My Subscription ID]/resourceGroups/[My ResourceGroup name]/providers/Microsoft.DataFactory/factories/[My Datafactory name]'  
  displayName: 'Validate'  
  
# Validate and then generate the ARM template into the destination folder, which is the same as selecting "Publish" from the UX.  
# The ARM template generated isn't published to the live version of the factory. Deployment should be done by using a CI/CD pipeline.   
  
- task: Npm@1  
  inputs:  
    command: 'custom'  
    workingDir: '$(Build.SourcesDirectory)/ADF'  
    customCommand: 'run build export $(Build.Repository.LocalPath)/ADF /subscriptions/[My Subscription ID]/resourceGroups/[My ResourceGroup name]/providers/Microsoft.DataFactory/factories/[My Datafactory name] "ArmTemplate"'  
  displayName: 'Validate and Generate ARM template'  
  
# Publish the artifact to be used as a source for a release pipeline.  
  
- task: PublishPipelineArtifact@1  
  inputs:  
    targetPath: '$(Build.Repository.LocalPath)/ADF/ArmTemplate'  
    artifact: 'ArmTemplates'  
    publishLocation: 'pipeline'  

Below is the error I am getting
82651-buildpipelinevalidationfailed-completeerrormessage.png

Package.json file was placed under '/ADF' folder. And below is the folder structure of my repo
82385-folderstructure.png

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,740 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Jay Vee 1 Reputation point
    2021-07-14T02:26:46.073+00:00

    From you YAML pipeline, choose the folder where the package-json is located

    0 comments No comments

  2. Sailesh Singh Chauhan 1 Reputation point
    2022-07-20T07:21:58.76+00:00

    I am using same YAML for automated deployment, I was also getting similar error.

    I am suggesting some changes in your YAML file. Please, implement them. I hope it will work for you also.

    1. You have kept package.json file inside ADF folder. I have kept it inside a folder called package in root directory not in ADF folder.
    2. At line number 31 and 41 I have used value for workingDir as this value '$(Build.Repository.LocalPath)/package' not '$(Build.SourcesDirectory)/ADF'
    3. At line number 49 for targetPath I have used '$(Build.Repository.LocalPath)/package/ArmTemplate' as value. This path should not make much difference.

    I expect if you will make suggested changes in point 1 and 2 your deployment would succeed

    Thanks

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.