Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Run Jenkins pipeline build using 'sh' step on 64-bit Windows 10

Run Jenkins pipeline build using 'sh' step on 64-bit Windows 10

Test script

pipeline {
    agent any

    stages {
        stage('Hello') {
            steps {
                sh label: '', script: '''#!/bin/bash
                    echo "hello world" 

Jenkins and Windows system configuration


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.

Useful Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.