forked from eclipse/xtext-umbrella
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adjustPipelines.sh
executable file
·103 lines (91 loc) · 2.11 KB
/
adjustPipelines.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
toDir() {
echo $1 | tr -d '\r'
}
name() {
git --git-dir "$(echo "$1" | tr -d '\r' | tr -d '\n')/.git" config --get remote.origin.url | sed 's/^.*\/\(xtext-[^\./]*\).*$/\1/'
}
branchname=${1:-master}
escaped() {
echo $branchname | sed 's/\//%252F/g'
}
escapedBranch=$(escaped)
isBranch() {
git show-branch "$branchname" &> /dev/null
}
isMaster() {
test $branchname = master
}
changeDir() {
pushd $1 > /dev/null
}
dropDir() {
popd > /dev/null
}
sed_inplace() {
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "$@"
else
sed -i "$@"
fi
}
if [[ -z "${JENKINS_URL}" ]]; then
JENKINS_URL="https://ci.eclipse.org/xtext"
fi
echo "JENKINS_URL=$JENKINS_URL"
./allDirectories | while read -r line
do
directory=$(toDir $line)
targets=$(echo $directory/releng/*.target)
if [[ -d $targets ]]
then
changeDir $directory
if isBranch
then
echo "Redirecting target platforms in $targets to $branchname"
dropDir
./allDirectories | while read -r repo
do
repository=$(toDir $repo)
if [[ $directory != $repository ]]
then
logicalname=$(name $repo)
if changeDir $repository
then
sed_inplace "s?<repository location=\".*/job/$logicalname/job/[^/]*/?<repository location=\"$JENKINS_URL/job/$logicalname/job/$escapedBranch/?" $targets/*.target
dropDir
fi
fi
done
else
dropDir
fi
fi
if [[ -d $directory ]]
then
changeDir $directory
if isBranch
then
dropDir
find $directory -name pom.xml -type f -path '*.maven.parent/*' -print -o -name pom.xml -type f -path '*.maven.plugin/src/test/resources/it/generate/pom.xml' -print -o -type f -path '*/releng/pom.xml' -print | while read -r pom
do
echo "Redirecting parent pom.xml files in $pom to $branchname"
./allDirectories | while read -r repo
do
repository=$(toDir $repo)
if [[ $directory != $repository ]]
then
logicalname=$(name $repo)
if changeDir $repository
then
sed_inplace "s?<upstreamBranch>.*</upstreamBranch>?<upstreamBranch>$escapedBranch</upstreamBranch>?" $pom
dropDir
fi
fi
done
done
else
dropDir
fi
fi
done