问题
I am creating a jenkins pipeline with stages. In this pipeline stages calls the powershell file and execute the needful and completed the task.
My issue here is, when executing the below code in one configured agent its working fine and in another agent when i trigger this pipeline job "term is not recognized as the name of a cmdlet, function, script file, or operable" error message is thrown in console. I am not sure why this stuff is happening.
pipeline{
agent {
label 'abc'
}
stages{
stage("SETUP"){
steps{
powershell returnStatus: true, script: "${filepath}\\abc.def.ps1 ${p1} ${p2} ${p3} ${p4} ${p5}"
}
}
stage("BUILD"){
steps{
powershell returnStatus: true, script: "${filepath}\\ghi.jkl.1.ps1 ${p1} ${p1}"
powershell returnStatus: true, script: "${filepath}\\ghi.jk1.1.ps1 ${p1} ${p1}"
}
}
}
}
Error message
term 'C:\Users\myuser\Desktop\New folder\abc.def.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Note 1: The same file is being configured using jenkins normal job and working fine
Note 2: The same is working fine in my another agent machine
回答1:
This issue is now resolved. The reason is because of the network drive mapping. On the time of execution there was no mapping to the network drive where the ps1 files are available
来源:https://stackoverflow.com/questions/58694035/term-c-users-myuser-desktop-new-folder-abc-def-ps1-is-not-recognized-as-the-n