-
Notifications
You must be signed in to change notification settings - Fork 0
/
ads.set.up.git.repo
executable file
·89 lines (67 loc) · 2.91 KB
/
ads.set.up.git.repo
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
#!/bin/bash
repo_basename=nerd-golf-tracker
repo="$HOME/git/$repo_basename.git"
tarball_timestamp=$(date +"%m_%d_%Y")
tarball_name=it-agile-nerd-golf-tracker.tar.gz
initial_sources=/tmp/$tarball_name
workspace="$HOME/integration_space/$repo_basename"
# Import initial sources
wget --output-document="$initial_sources" --no-check-certificate https://github.com/it-agile/nerd-golf-tracker/tarball/master
# Copies last used archives, if you do not have a internet connection, could use
# an older version, copy to /tmp and do not use wget
mkdir "tarball_archive"
cp $initial_sources "tarball_archive/$tarball_name.$tarball_timestamp"
# Init repo
rm -rf "$repo"
mkdir -p "$repo"
git init --bare "$repo"
# Setup dir for importing sources
rm -rf "$workspace"
mkdir -p "$workspace"
cd "$workspace"
cd ..
git clone "$repo"
cd "$workspace"
tar -xzf "$initial_sources" --strip-components=1
git add --all
git commit -m 'initial commit'
git push -u origin master
####################################################################
# Set this machine as repository
####################################################################
ipOf() {
LC_ALL=C ifconfig "$1" \
| grep inet\ addr \
| cut -f 2 -d : \
| cut -f 1 -d " "
}
local_ip=`ipOf eth0` # First try IP of eth0, if we serve as an internet bridge
if [ -z $local_ip ]; then local_ip=`ipOf wlan0`; fi # Next try IP of wlan
if [ -z $local_ip ]; then local_ip="<IP-Adresse>"; fi # Fallback: Insert dummy string
sed -i -e "s/localhost/$local_ip/" build.gradle gradle/wrapper/gradle-wrapper.properties
git add --all
git commit -m 'Use integration machine as artifact repository'
git push origin master
####################################################################
# Nexus
####################################################################
nexus_storage="$HOME/local/sonatype-work/nexus/storage"
# Download Gradle unless already present
gradle_version=$(grep 'gradleVersion =' build.gradle | cut -d\' -f 2)
gradle_dist_group_path="$nexus_storage/releases/org/gradle/gradle/$gradle_version"
mkdir -p "$gradle_dist_group_path"
gradle_dist_artifact_path="$gradle_dist_group_path/gradle-$gradle_version-bin.zip"
if [ ! -f $gradle_dist_artifact_path ]; then
wget --output-document="$gradle_dist_artifact_path" "https://services.gradle.org/distributions/gradle-$gradle_version-bin.zip"
fi
gradle_dist_artifact_path="$gradle_dist_group_path/gradle-$gradle_version-all.zip"
if [ ! -f $gradle_dist_artifact_path ]; then
wget --output-document="$gradle_dist_artifact_path" "https://services.gradle.org/distributions/gradle-$gradle_version-all.zip"
fi
# Remove Nexus artifacts
rm -f "$nexus_storage/snapshots/de/itagile/golf/nerd-golf-tracker/1.0-SNAPSHOT"/*
####################################################################
# misc
####################################################################
# Remove Jenkins jobs
rm -rf $HOME/.jenkins/jobs/*