詹金斯 - cmd无法识别 [英] Jenkins - cmd is not recognized

查看:20
本文介绍了詹金斯 - cmd无法识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Environment:

  • Master Linux Jenkins server
  • Two Windows slave nodes
  • The windows slaves are running as a service

First Test

  • I create a Pipeline and use a use a "Execute Windows batch command" in the build section
  • In the Command box I put "C:Jenkinsmytest.bat"
  • I checked the box "Restrict where this project can be run" and write down the name of the Windows slave
  • I built the pipeline and was successful

Second Test

  • I create a Declarative Pipeline as follows:

    pipeline {  
        agent { label 'SiebelWindows' }
    
        stages {
            stage('Test Bat') {
               steps { 
                            bat 'C:\Jenkins\mytest.bat'
                            //bat 'start cmd.exe /c C:\Jenkins\mytest.bat'
                            //call C:\Jenkins\mytest.bat
                            }
                    }
        }
       }
    

  • In this case the build FAIL with error "cmd is not recognized as a internal o external command"

So, why can I run the .bat with a non-declarative pipeline, but fails with a declarative pipeline?

解决方案

When I display the "Path" and the "PATH" variables, this was the result

Original_Path

The solution was redefine the PATH enviorement variable, like this

environment {

    PATH = "C:\WINDOWS\SYSTEM32"

}

@JustAProgrammer aske me if C:WINDOWSSYSTEM32 was in the PATH of my Windows machine, and that is correct, but seems like Jenkins master do not know the slave's Windows Path.

I resolve my issue, but I still looking for a complete solution, I need to set the PATH enviorement variable with ALL the path, no only C:WINDOWSSYSTEM32

这篇关于詹金斯 - cmd无法识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆