Forum Discussion
nileshtdhone
Jul 25, 2024Copper Contributor
How to run the batch file in Test node from Azure pipelines.
I have batch file in test node shared folder and wanted to execute through the pipeline.
- sdtslmnBrass Contributor
First Ensure that your Azure Pipeline agent is running on the test node itself
Then
Use either the BatchScript task or the CmdLine task
example for BatchScript
# ... your pipeline stages ... - stage: Test jobs: - job: RunBatchFile pool: vmImage: 'windows-latest' # Or specify your agent pool that runs on the test node steps: - task: BatchScript@1 inputs: filename: '\\<test-node-name>\<shared-folder-path>\<your-batch-file>.bat' # Replace with the actual path # arguments: '...' # Optional: Add arguments for your batch file
and
example for CmdLine
# ... your pipeline stages ... - stage: Test jobs: - job: RunBatchFile pool: vmImage: 'windows-latest' steps: - task: CmdLine@2 inputs: script: 'call \\<test-node-name>\<shared-folder-path>\<your-batch-file>.bat' # add any additional arguments to the script if necessary
- nileshtdhoneCopper Contributor
sdtslmn test node and agent node are different nodes.
- sdtslmnBrass Contributor
so ensure that the Azure Pipeline agent has the necessary network and file share access to the test node's shared folder.
then we can update the CmdLine Task accordingly
# Your pipeline YAML file stages: - stage: Test jobs: - job: RunBatchFile pool: vmImage: 'windows-latest' # Or specify your agent pool steps: - task: CmdLine@2 inputs: script: | net use \\<test-node-name>\<shared-folder-path> /user:<YourUsername> <YourPassword> call \\<test-node-name>\<shared-folder-path>\<your-batch-file>.bat net use \\<test-node-name>\<shared-folder-path> /delete