I need to write the pipeline which sends my .jar file to remote windows server (done). And most important – I need to launch an existing .cmd on my remote windows machine through Jenkins pipeline (I got Linux Jenkins server). Having troubles with running .cmd.
Tried SSH, WinRM
- got connection refuse
- got $ powershell -NonInteractive “& ‘/tmp/jenkins14634104006026213935.ps1′”
FATAL: Cannot run program “powershell”: error=2, Нет такого файла или каталога
<code>pipeline {
agent any
environment {
WINDOWS_HOST = "my-host"
SCRIPT_PATH = "my-path"
CREDENTIALS_ID = "my-creds"
}
stages {
stage('Run CMD Script on Windows') {
steps {
script {
winRMClient credentialsId: CREDENTIALS_ID, hostName: WINDOWS_HOST,
winRMOperations: [invokeCommand('C:\publish\script.bat')]
}
}
}
}
}
</code>
<code>pipeline {
agent any
environment {
WINDOWS_HOST = "my-host"
SCRIPT_PATH = "my-path"
CREDENTIALS_ID = "my-creds"
}
stages {
stage('Run CMD Script on Windows') {
steps {
script {
winRMClient credentialsId: CREDENTIALS_ID, hostName: WINDOWS_HOST,
winRMOperations: [invokeCommand('C:\publish\script.bat')]
}
}
}
}
}
</code>
pipeline {
agent any
environment {
WINDOWS_HOST = "my-host"
SCRIPT_PATH = "my-path"
CREDENTIALS_ID = "my-creds"
}
stages {
stage('Run CMD Script on Windows') {
steps {
script {
winRMClient credentialsId: CREDENTIALS_ID, hostName: WINDOWS_HOST,
winRMOperations: [invokeCommand('C:\publish\script.bat')]
}
}
}
}
}
I tried different script types such as .bat, .sh,
What i need is
<code>@sc stop my_app
@timeout 5
@xcopy C:publishmy_appmy_app.jar C:Servermy_app /Y /D
@sc start my_app
~
</code>
<code>@sc stop my_app
@timeout 5
@xcopy C:publishmy_appmy_app.jar C:Servermy_app /Y /D
@sc start my_app
~
</code>
@sc stop my_app
@timeout 5
@xcopy C:publishmy_appmy_app.jar C:Servermy_app /Y /D
@sc start my_app
~
I need this to run on my remote Windows using Jenkins Pipeline
How can i do it?
New contributor
Alexander Tkachenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.