Search code examples
azure-devopsyamlazure-data-factory

Unable to Determine Path to Powershell Script when deploying CI/CD pipelines in Azure Data Factoy with AzureDevOps


I have been getting some help with deploying pipelines using yaml code with Azure DevOps by a very helpful person called @Alvin.

The problem I'm having is establishing the actual path to certain files - in this case, a Powershell script called pre-and post-deployment.ps1

The code is as follows:

# 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:
- main

pool:
  vmImage: ubuntu-latest

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

- script: |
    echo Add other tasks to build, test, and deploy your project.
    echo See https://aka.ms/yaml
  displayName: 'Run a multi-line script'
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'
- task: AzurePowerShell@5
  inputs:
    azureSubscription: 'NewConnectionName'
    ScriptType: 'FilePath'
    ScriptPath: '$(System.DefaultWorkingDirectory)/caplogic-warehouse-dev-df/pre-and post-deployment.ps1'
    azurePowerShellVersion: 'LatestVersion'

When I run the script I get the error:

##[error]ENOENT: no such file or directory, stat '/home/vsts/work/1/s/caplogic-warehouse-dev-df/pre-and post-deployment.ps1'

I'm strugging to establish the actual path to the file.

I have tried to figure out the path using the path details from the following image: enter image description here

However, the path I used from the image is incorrect, so I don't know how to establish the path.

I was hoping the Job run would show the path, image below. However,the path isn't shown here. enter image description here

However, there is a way of getting path as shown in following image, however I'm not getting the path in my job run.

https://i.sstatic.net/Tp9fkX7J.png

So, the question is can someone help establish the correct path to the powershell script?

I have modified the script to use adf_publish, and added the tree command, see image, but it still keeps on pointing main

enter image description here

enter image description here

When I try to switch to adf-publish, see image enter image description here

I get the following error: enter image description here

Do I need to manually upload the azure-pipelines-5.yml?

I uploaded the file as suggested by @Wade and it worked :-) enter image description here

I'm now having a problem with the powershell script itself, see image, but I will raise another ticket for that enter image description here


Solution

  • As per your yaml, it appears it's main branch, but the file is in adf_publish branch. Please check if the build is executed on correct branch.

    With correct branch on my side, the same yaml works for me.

    In addition, you can use tree command to get the file list for confirmation.

    pool:
      vmImage: ubuntu-latest
    
    steps:
    - script: |
        tree
    

    enter image description here

    Edit: You are still running on main branch.

    If you have the same named yaml in adf_publish branch, simply change the branch to run.

    enter image description here

    If you don't have the yaml in adf_publish branch, on main branch -> download the yaml file -> go to adf_publish branch, upload the yaml.

    After it's done, edit the pipeline to choose the adf_publish branch.

    enter image description here