-
Notifications
You must be signed in to change notification settings - Fork 134
/
Copy pathgit-jenkins3.sh
62 lines (56 loc) · 2.47 KB
/
git-jenkins3.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
#
# Licensed materials - Property of IBM
# 5655-AC5 Copyright IBM Corp. 2018, 2018
# All rights reserved
# US Government users restricted rights - Use, duplication or
# disclosure restricted by GSA ADP schedule contract with IBM Corp.
#
# Support credential management in Jenkins for git client plugin < 3.0
#
###################################################################
# Set current dir to direct temp outputs to @tmp dir
currentdir=$(pwd)
# git operating via HTTP/S
# Setting encoding of temporary files for git askpass
# Redirect of output is mandatory
if test -n "$SSH_ASKPASS"; then
if test -f "$SSH_ASKPASS"; then
# check the current tag, if ibm-1047 don't iconv
chtag -p $SSH_ASKPASS | grep -q "IBM-1047" >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
if [ $? -eq 0 ]; then
echo 'file already in ibm-1047' >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
else
chtag -p $SSH_ASKPASS >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
chtag -t -c UTF-8 $SSH_ASKPASS >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
iconv -f utf-8 -T -t IBM-1047 $SSH_ASKPASS > $SSH_ASKPASS.tmp
mv $SSH_ASKPASS.tmp $SSH_ASKPASS >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
chmod 700 $SSH_ASKPASS >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
fi
fi
fi
# git operating via SSH
if test -n "$GIT_SSH"; then
if test -f "$GIT_SSH"; then
chtag -p $GIT_SSH | grep -q "IBM-1047" >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
if [ $? -eq 0 ]; then
echo 'file already in ibm-1047' >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
else
chtag -p $GIT_SSH >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
chtag -t -c UTF-8 $GIT_SSH >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
iconv -f utf-8 -T -t IBM-1047 $GIT_SSH > $GIT_SSH.tmp
mv $GIT_SSH.tmp $GIT_SSH >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
chmod 700 $GIT_SSH >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
keyFile=$(cat $GIT_SSH | grep "ssh -i" | sed 's/^[^"]*"\([^"]*\)".*/\1/')
if test -n "$keyFile"; then
chtag -p $keyFile >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
chtag -t -c UTF-8 $keyFile >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
iconv -f utf-8 -T -t IBM-1047 $keyFile > $keyFile.tmp
mv $keyFile.tmp $keyFile >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
chmod 600 $keyFile >>$currentdir@tmp/git-jenkins-wrapper.log 2>&1
fi
fi
fi
fi
#git "$@" | iconv -f ibm-1047 -t ibm-1047
git "$@"