Jenkins pipeline中执行bat一直执行,直至手动取消

在win7系统中安装了Jenkins-2.319.1版本,以java启动war包的方式启动了Jenkins,成功安装pipeline插件后重启并新建了pipline任务,编写脚本如下:
pipeline{
agent any
stages{
stage (‘整体功能测试’){
steps{
echo “aaaa”
bat ‘’’
echo “11222”
‘’’
}
}
}
结果Jenkins构建时一直在bat处执行,不停止也无任何报错,直至手动无效,如图:


请问这是什么原因,该怎么解决

I believe the translation of the question is something like:

The Jenkins-2.319.1 version is installed in the win7 system, and Jenkins is started by starting the war package in java. After the pipeline plugin is successfully installed, it restarts and creates a new pipline task. The script is written as follows:
pipeline{
agent any
stages{
stage (‘overall functional test’){
steps{
echo “aaaa”
bat ‘’’
echo “11222”
‘’’
}
}
}
As a result, Jenkins has been executed at bat during construction, without stopping or reporting any errors, until the manual is invalid, as shown in the figure:

Please what is the reason for this and how to solve it

I think you’re asking why does Jenkins cancel execution of a Pipeline job when the controller is running on Windows 7. As far as I know, none of the Jenkins developers test with Windows 7. Windows 7 has been unsupported by Microsoft for over two years.

I am surprised that the job would be cancelled without action from the user, but I’m not aware of anyone willing to investigate a failure on Windows 7.

Some of the things you might check:

  • Confirm that you’re running a recent version of Java (preferably 11.0.14 or 8u322). If you’re running a version newer than 11.0.14 (like Java 15, 16, or 17), switch back to Java 11
  • Confirm that there is enough memory and disc space on the computer to run Jenkins
  • Confirm that the Jenkins version you’re running is a recent release (2.319.3 or 2.334)
  • Confirm that the operating system has whatever patches are available for it (I don’t know if patches are available any longer for Windows 7)

I may not express my problem clearly and the job will not be cancelled if the user does not take action.The problem I want to express is: IN Jenkins’ pipeline script, I set the command to execute the BAT batch processing script. After setting the command, the pipeline task was always in execution during the construction task, no error would be reported, and the execution would not be completed. Therefore, I manually cancelled the execution of this task.

Regarding your questions and suggestions:

  1. Jenkins deployed to Windows 7 because our program had to run on Windows.
  2. I have also tried to deploy and execute in Win10. This problem also exists in BAT batch script commands in Win10, but powershell commands do not have this problem.
    3, Make sure you are using Java 11, Jenkins-2.319.3, the computer has enough memory and disk space, this problem still exists;

I don’t know if the sample you pasted was incorrectly copied or if you are actually using those alternate quote forms (“smart quotes, etc.”) in the Pipeline script. They won’t work. You need to use ASCII single quote and double quote when defining strings in the Pipeline domain specific language.

I created the following working Pipeline script from yours, but using ASCII characters instead of the alternate forms:

pipeline {
    agent {
        label 'windows'
    }
    stages {
        stage ('overall functional test') {
            steps {
                echo 'aaaa'
                bat '''
echo "11222"
'''
            }
        }
    }
}

I reconfirmed that it should not be the problem of quotation marks. I have tried the quotation marks of ASCII code, but this problem still exists.

There will be problems when using the bat command. The script is as follows:

The powshell command is successful. The script is as follows:
pipeline{
agent any

stages{
    stage ('testing'){
        steps{
            echo 'aaaa'
            powershell 'python -V'
        } 
    }
    
}

}

The only difference between the two is that bat and powshell commands are the same, so I think it’s still about bat, and I don’t know what this problem is.

I can’t duplicate the problem. The following two Pipeline job definitions behave correctly for me:

Batch

pipeline {
    agent {
        label 'windows && python'
    }

    stages{
        stage ('testing'){
            steps{
                echo 'aaaa'
                bat 'python -V'
            } 
        }
    }
}

Powershell

pipeline {
    agent {
        label 'windows && python'
    }

    stages{
        stage ('testing'){
            steps{
                echo 'aaaa'
                powershell 'python -V'
            } 
        }
    }
}

You may want to check if the problem can be duplicated on other Windows computers in your environment. There may be something configured on that specific Windows 7 computer that causes the odd behavior.