-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
157 lines (131 loc) · 5.57 KB
/
Jenkinsfile
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
def notify(status){
emailext (
body: '$DEFAULT_CONTENT',
recipientProviders: [
[$class: 'CulpritsRecipientProvider'],
[$class: 'DevelopersRecipientProvider'],
[$class: 'RequesterRecipientProvider']
],
replyTo: '$DEFAULT_REPLYTO',
subject: '$DEFAULT_SUBJECT',
to: '$DEFAULT_RECIPIENTS'
)
}
@NonCPS
def killall_jobs() {
def jobname = env.JOB_NAME
def buildnum = env.BUILD_NUMBER.toInteger()
def killnums = ""
def job = Jenkins.instance.getItemByFullName(jobname)
def fixed_job_name = env.JOB_NAME.replace('%2F','/')
for (build in job.builds) {
if (!build.isBuilding()) { continue; }
if (buildnum == build.getNumber().toInteger()) { continue; println "equals" }
if (buildnum < build.getNumber().toInteger()) { continue; println "newer" }
echo "Kill task = ${build}"
killnums += "#" + build.getNumber().toInteger() + ", "
build.doStop();
}
if (killnums != "") {
slackSend color: "danger", channel: "#jenkins", message: "Killing task(s) ${fixed_job_name} ${killnums} in favor of #${buildnum}, ignore following failed builds for ${killnums}"
}
echo "Done killing"
}
def buildStep(ext, hostFlags = '', sysRoot = true) {
def fixed_job_name = env.JOB_NAME.replace('%2F','/')
def sysRootEnv = ''
try{
stage("Building ${ext}...") {
properties([pipelineTriggers([githubPush()])])
if (env.CHANGE_ID) {
echo 'Trying to build pull request'
}
if (sysRoot) {
sysRootEnv = "--sysroot=/opt/toolchains/${ext}/"
}
def commondir = env.WORKSPACE + '/../' + fixed_job_name + '/'
checkout scm
if (!env.CHANGE_ID) {
sh "rm -rfv ${env.WORKSPACE}/publishing/deploy/*"
sh "mkdir -p ${env.WORKSPACE}/publishing/deploy/ilbmtoicon"
}
slackSend color: "good", channel: "#jenkins", message: "Starting ${ext} build target..."
freshUpRoot(ext)
if (!env.CHANGE_ID) {
sh "mkdir -p ${env.WORKSPACE}/publishing/deploy/ilbmtoicon/${ext}/"
}
sh "cd ${env.WORKSPACE}/ && make -j8 clean"
sh "cd ${env.WORKSPACE}/ && CC=\"ccache ${ext}-gcc ${sysRootEnv}\" HOST_LIBPNG=\"-lpng -lm\" HOST_STRIP=\"${ext}-strip\" HOST_CFLAGS=\"${hostFlags}\" HOST_LDFLAGS=\"${hostFlags}\" CPP=\"ccache ${ext}-cpp ${sysRootEnv}\" CXX=\"ccache ${ext}-g++ ${sysRootEnv}\" make -j8 "
sh "cd ${env.WORKSPACE}/ && mv -fv ilbmtoicon infoinfo ${env.WORKSPACE}/publishing/deploy/ilbmtoicon/${ext}/"
sh "cd ${env.WORKSPACE}/ && cp -fvr README.md LICENSE ${env.WORKSPACE}/publishing/deploy/ilbmtoicon/${ext}/"
if (!env.CHANGE_ID) {
sh "cd ${env.WORKSPACE}/publishing/deploy/ilbmtoicon/${ext}/ && lha c ../ilbmtoicon-${ext}.lha *"
sh "rm -rfv ${env.WORKSPACE}/publishing/deploy/ilbmtoicon/${ext}/*"
sh "echo '${env.BUILD_NUMBER}|${env.BUILD_URL}' > ${env.WORKSPACE}/publishing/deploy/ilbmtoicon/${ext}/BUILD"
sh "mv -fv ${env.WORKSPACE}/publishing/deploy/ilbmtoicon/ilbmtoicon-${ext}.lha ${env.WORKSPACE}/publishing/deploy/ilbmtoicon/${ext}/"
}
if (env.TAG_NAME) {
sh "echo $TAG_NAME > ${env.WORKSPACE}/publishing/deploy/STABLE"
sh "ssh $DEPLOYHOST mkdir -p public_html/downloads/releases/ilbmtoicon/$TAG_NAME"
sh "scp -r ${env.WORKSPACE}/publishing/deploy/ilbmtoicon/* $DEPLOYHOST:~/public_html/downloads/releases/ilbmtoicon/$TAG_NAME/"
sh "scp ${env.WORKSPACE}/publishing/deploy/STABLE $DEPLOYHOST:~/public_html/downloads/releases/ilbmtoicon/"
} else if (env.BRANCH_NAME.equals('master')) {
def deploy_url = sh (
script: 'echo "nightly/ilbmtoicon/`date +\'%Y\'`/`date +\'%m\'`/`date +\'%d\'`/"',
returnStdout: true
).trim()
sh "date +'%Y-%m-%d %H:%M:%S' > ${env.WORKSPACE}/publishing/deploy/BUILDTIME"
sh "ssh $DEPLOYHOST mkdir -p public_html/downloads/nightly/ilbmtoicon/`date +'%Y'`/`date +'%m'`/`date +'%d'`/"
sh "scp -r ${env.WORKSPACE}/publishing/deploy/ilbmtoicon/* $DEPLOYHOST:~/public_html/downloads/nightly/ilbmtoicon/`date +'%Y'`/`date +'%m'`/`date +'%d'`/"
sh "scp ${env.WORKSPACE}/publishing/deploy/BUILDTIME $DEPLOYHOST:~/public_html/downloads/nightly/ilbmtoicon/"
slackSend color: "good", channel: "#jenkins", message: "Deploying ${fixed_job_name} #${env.BUILD_NUMBER} Target: ${ext} to web (<https://dl.amigadev.com/${deploy_url}|https://dl.amigadev.com/${deploy_url}>)"
} else {
slackSend color: "good", channel: "#jenkins", message: "Build ${fixed_job_name} #${env.BUILD_NUMBER} Target: ${ext} successful!"
}
}
} catch(err) {
slackSend color: "danger", channel: "#jenkins", message: "Build Failed: ${fixed_job_name} #${env.BUILD_NUMBER} Target: ${ext} (<${env.BUILD_URL}|Open>)"
currentBuild.result = 'FAILURE'
notify('Build failed')
throw err
}
}
def freshUpRoot(ext) {
def commondir = env.WORKSPACE + '/../' + env.JOB_NAME.replace('%2F','/') + '/'
sh "rm -rfv ${env.WORKSPACE}/build-${ext}"
//sh "mkdir -p ${env.WORKSPACE}/build-${ext}"
}
def postCoreBuild(ext) {
}
node('master') {
killall_jobs()
def fixed_job_name = env.JOB_NAME.replace('%2F','/')
slackSend color: "good", channel: "#jenkins", message: "Build Started: ${fixed_job_name} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
parallel (
'Build AmigaOS3.x version': {
node {
buildStep('m68k-amigaos','-noixemul -m68020-60 -msoft-float')
}
},
'Build AmigaOS4.x version': {
node {
buildStep('ppc-amigaos','-I/opt/toolchains/ppc-amigaos/include -L/opt/toolchains/ppc-amigaos/lib',false)
}
},
'Build MorphOS version': {
node {
buildStep('ppc-morphos')
}
},
'Build WarpOS version': {
node {
buildStep('ppc-warpos','-v -specs=warpup -D__WARPOS__')
}
},
'Build Linux-x86_64 version': {
node {
buildStep('x86_64-linux-gnu','',false)
}
}
)
}