[JIRA] (JENKINS-57542) git checkout over ssh fails on windows agents started from msys2 - missing bat file

11 views
Skip to first unread message

mark.earl.waite@gmail.com (JIRA)

unread,
May 19, 2019, 1:55:02 PM5/19/19
to jenkinsc...@googlegroups.com
Mark Waite updated an issue
 
Jenkins / Bug JENKINS-57542
git checkout over ssh fails on windows agents started from msys2 - missing bat file
Change By: Mark Waite
Summary: git checkout over ssh fails on some windows agents because . started from msys2 - missing bat file is missing
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

jenkins2017@gi2.herzkes.de (JIRA)

unread,
May 20, 2019, 4:53:01 AM5/20/19
to jenkinsc...@googlegroups.com
T Herzke commented on Bug JENKINS-57542
 
Re: git checkout over ssh fails on windows agents started from msys2 - missing bat file

I can see how running jenkins agent from a unix shell on windows is unusual.

Reason is my builds are cross-platform (linux, mac, windows) but require bash on every platform. I have found in the past that starting the jenkins agent as a child process of the shell I want to use gives me the least trouble to achieve this on windows. I have used, cygwin, msys, msys2, to achieve this so far with no trouble.

Starting Jenkins agent from batch file is an alternative that I'm investigating now but the shell commands from Jenkinsfiles like sh "make sometarget" and their child processes show strange behaviour when I do this, like pretending they were called without parameters.

jenkins2017@gi2.herzkes.de (JIRA)

unread,
May 20, 2019, 3:44:02 PM5/20/19
to jenkinsc...@googlegroups.com
T Herzke commented on Bug JENKINS-57542

Workaround recipe:

1) Identify additional environment variables and their values when starting the msys2 bash via start menu vs by invoking bash.exe from cmd.exe.

2) Create bash skript that sets these environment variables in multiple export NAME=value lines, also add the extended PATH value. Store as jenkins.env in msys2 root folder.

3) In the Jenkinsfiles, define custom step windows_bash

def windows_bash(command) {
  bat ('C:\\msys64\\usr\\bin\\bash -c "source /jenkins.env && ' + command + ' "')
}

4) In the Jenkinsfiles, define a delegating custom step that forwards to either sh or windows_bash depending on the operating system of the Agent

def bash(command) {
  windows() ? windows_bash(command) : sh(command)
}

where windows() has to be defined to return true only for windows agents.

5) In all places in the Jenkinsfile where a shell command could be executed either on windows or on Unix, use bash "command" instead of sh "command"

jenkins2017@gi2.herzkes.de (JIRA)

unread,
May 20, 2019, 3:47:03 PM5/20/19
to jenkinsc...@googlegroups.com
T Herzke closed an issue as Won't Fix
 

The problem occurs under special circumstances that are probably outside of the scope of Jenkins.

Change By: T Herzke
Status: Open Closed
Resolution: Won't Fix

jenkins2017@gi2.herzkes.de (JIRA)

unread,
May 20, 2019, 3:48:02 PM5/20/19
to jenkinsc...@googlegroups.com
T Herzke edited a comment on Bug JENKINS-57542
 
Re: git checkout over ssh fails on windows agents started from msys2 - missing bat file
The problem occurs under special circumstances that are probably outside of the scope of Jenkins. Closed as won't-fix.
Reply all
Reply to author
Forward
0 new messages