下面的管道脚本正在Kubernetes中的Jenkins示例中工作:
podTemplate(yaml: '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: jnlp
image: jenkins/inbound-agent:nanoserver-1809
- name: sidecar
image: mcr.microsoft.com/dotnet/aspnet:6.0.15-windowsservercore-ltsc2019
nodeSelector:
kubernetes.io/os: windows
''') {
node(POD_LABEL) {
container(name: 'sidecar', shell: 'cmd.exe') {
echo "hello-world"
}
}
}
然而,我很难用一个批处理脚本替换echo "hello-world"
。dir
"dir"
bat 'dir'
bat "dir"
`bat ```dir````
典型的错误消息是
[Pipeline] { (hide)
[Pipeline] container
[Pipeline] {
[Pipeline] bat
ERROR: Process exited immediately after creation. See output below
Executing cmd.exe script inside container sidecar of pod simple-batch-44-0z85v-kb7cj-pncc6
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
ERROR: Process exited immediately after creation.
执行任意批处理命令(如“dir”)的正确语法是什么?
1条答案
按热度按时间frebpwbc1#
单独运行
dir
或bat 'dir'
会失败,但在给定路径时会成功。例如
bat 'dir c:\\'
。有趣的是PowerShell的行为不同。运行powershell 'Get-ChildItem'
成功