Skip to content

Commit f818197

Browse files
authored
Merge pull request #148 from siddharthvipul/addPipeline
add pipeline script to automate build through Jenkins
2 parents b35cfcd + bce7b35 commit f818197

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

docker/.cico.pipeline

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
def c7arches = ["ppc64le", "x86_64", "aarch64"]
2+
3+
4+
def onmyduffynode(script){
5+
ansiColor('xterm'){
6+
timestamps{
7+
sh 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root ${DUFFY_NODE}.ci.centos.org -t \"export REPO=${REPO}; export BRANCH=${BRANCH};\" "' + script + '"'
8+
}
9+
}
10+
}
11+
12+
13+
def syncfromduffynode(rsyncpath){
14+
sh 'rsync -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root " -Ha --include=' + rsyncpath + " ${DUFFY_NODE}.ci.centos.org:~/ ./"
15+
}
16+
17+
18+
def synctoduffynode(source){
19+
sh 'scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r ' + source + " " + "root@" + "${DUFFY_NODE}.ci.centos.org:~/"
20+
}
21+
22+
23+
node('sig-cloudinstance'){
24+
stage('make placeholder'){
25+
env.time_stamp = sh(
26+
script: "date +%y%m%d",
27+
returnStdout: true
28+
).trim()
29+
30+
env.rsync_key = sh(
31+
script: "head -c 13 ~/duffy.key",
32+
returnStdout: true
33+
)
34+
35+
sh 'mkdir -p /tmp/centos-7-${time_stamp}'
36+
sh "RSYNC_PASSWORD='${rsync_key}' rsync -av /tmp/centos-7-${time_stamp} sig-cloudinstance@artifacts.ci.centos.org::sig-cloudinstance/"
37+
38+
}
39+
40+
stage('Checkout'){
41+
checkout scm
42+
}
43+
44+
c7arches.each { arch ->
45+
stage("c7-$arch") {
46+
try{
47+
stage ("Allocate node"){
48+
env.CICO_API_KEY = readFile("${env.HOME}/duffy.key").trim()
49+
duffy_rtn=sh(
50+
script: "cico --debug node get --arch ${arch} -f value -c hostname -c comment",
51+
returnStdout: true
52+
).trim().tokenize(' ')
53+
env.DUFFY_NODE = duffy_rtn[0]
54+
env.DUFFY_SSID = duffy_rtn[1]
55+
}
56+
stage ("setup"){
57+
onmyduffynode "yum -y install rsync docker lorax anaconda-tui yum-langpacks virt-install libvirt-python"
58+
synctoduffynode "docker/centos-7-${arch}.ks"
59+
synctoduffynode "docker/containerbuild.sh"
60+
}
61+
62+
stage("build boot.iso"){
63+
onmyduffynode "./containerbuild.sh centos-7-${arch}.ks"
64+
}
65+
66+
stage("tag the container"){
67+
env.time_stamp = sh(
68+
script: "date +%Y%m%d",
69+
returnStdout: true
70+
)
71+
onmyduffynode 'systemctl start docker'
72+
onmyduffynode "cat /var/tmp/containers/*/centos-7-${arch}/docker/centos-7-${arch}-docker.tar.xz | docker import - centos:7"
73+
onmyduffynode "docker tag centos:7 centos:centos7"
74+
onmyduffynode "docker tag centos:7 centos:centos7.6.${time_stamp}"
75+
onmyduffynode "docker tag centos:7 centos:7.6.${time_stamp}"
76+
onmyduffynode "docker tag centos:7 centos:latest"
77+
}
78+
79+
stage("push to artifacts"){
80+
81+
env.time_stamp = sh(
82+
script: "date +%y%m%d",
83+
returnStdout: true
84+
).trim()
85+
86+
env.rsync_key = sh(
87+
script: "head -c 13 ~/duffy.key",
88+
returnStdout: true
89+
)
90+
91+
92+
onmyduffynode "mkdir -p /tmp/centos-7-${time_stamp}/${arch}"
93+
94+
onmyduffynode "cp -r /var/tmp/containers/*/centos-7-${arch}/docker/*tar.xz /tmp/centos-7-${time_stamp}/${arch}"
95+
96+
onmyduffynode "RSYNC_PASSWORD='${rsync_key}' rsync -av /tmp/centos-7-${time_stamp}/${arch}/ sig-cloudinstance@artifacts.ci.centos.org::sig-cloudinstance/centos-7-${time_stamp}/${arch}/"
97+
}
98+
}
99+
100+
catch (e){
101+
currentBuild.result = "FAILURE"
102+
throw e
103+
}
104+
finally{
105+
stage("Cleanup"){
106+
sh 'cico node done ${DUFFY_SSID}'
107+
}
108+
}
109+
}
110+
}
111+
}
112+

0 commit comments

Comments
 (0)