pipeline {
agent any
stages {
stage('Hello') {
steps {
sh label: '', script: '''#!/bin/bash
echo "hello world"
'''
}
}
}
}
Since the git install is 64-bit both Jenkins and the agent must be running with 64-bit Java.
In my case Jenkins is running as a Windows service. Configuration for that service is contained in the file jenkins.xml
in the root install folder (in my case c:\jenkins
). Jenkins ships with a 32-bit Java VM.
In jenkins.xml
need to replace:
<executable>%BASE%\jre\bin\java</executable>
with
<executable>C:\Program Files\Java\jre1.8.0_121\bin\java</executable>
(need full path to java executable)
Also need to configure the "Shell Executable" in Jenkins UI under "Configure System"
c:\program files\git\git-bash.exe
Need to use the backslash, not the forward slash like usual when using Windows paths in Java applications.
Also need to add two git folders to the Windows system path:
C:\Program Files\Git\bin
C:\Program Files\Git\usr\bin
System does not need to be restarted, just restart the Jenkins service.
- invoking bash from jenkins ci job blocks forever · Issue #2217 · microsoft/WSL · GitHub
- bash - Jenkins pipeline sh fail with "cannot run program nohup" on windows - Stack Overflow
- wsl.exe is not found when run from Jenkins · Issue #2889 · microsoft/WSL · GitHub
- https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+as+a+Windows+service