term <C:\Users\myuser\Desktop\New folder\abc.def.ps1> is not recognized as the name of a cmdlet, function, script file, or operable

放肆的年华 提交于 2020-01-07 09:23:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!