Reputation: 489
I am using the Azure DevOps server pipeline shell script task when I passed the "$(Build.SourcesDirectory)" variable as a shell script arguments, I found the path is not getting "/" while printing the variable.
Here is the Azure DevOps Pipeline Task:
Here is my shell script:
!/bin/bash echo $1
Here is the output of the pipeline:
please give some idea how I can get actual path (with "/") while printing the variable?
Upvotes: 2
Views: 1367
Reputation: 489
I found the solution. I have added Azure DevOps Server 2019 predefine variable as extra vars in azure-pipelines.yml like this:
- task: Ansible@0
inputs:
ansibleInterface: 'agentMachine'
playbookPathOnAgentMachine: 'ansible/tfs_playbooks/install_agent.yml'
inventoriesAgentMachine: 'file'
inventoryFileOnAgentMachine: 'hosts.yml'
args: '--extra-vars "build_source_dir=$(Build.SourcesDirectory)"'
Then I can access the variable in my playbook using this:
---
- hosts: localhost
tasks:
- name: show debug
debug:
msg: "Dir {{ build_source_dir }}"
Upvotes: 1
Reputation: 19016
If I am not guess wrong, the agent this pipeline is using located in Windows?
Please try with the pass the variable as $BUILD_SOURCESDIRECTORY
without any double or single quote(s).
Upvotes: 0