-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathJenkinsfile
87 lines (87 loc) · 2.42 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
pipeline {
agent none
parameters {
booleanParam(name: 'UPLOAD_AND_CACHE', defaultValue: true, description: 'Also do stages upload and cache')
}
options {
newContainerPerStage()
}
environment {
LC_ALL = 'C.UTF-8'
}
stages {
stage('update') {
agent {
dockerfile {
filename '.CI/OMPython/Dockerfile'
label 'linux'
args "-v /var/lib/jenkins/gitcache:/var/lib/jenkins/gitcache"
}
}
environment {
HOME = '/tmp/dummy'
GITHUB_AUTH = credentials('OpenModelica-Hudson')
}
steps {
sh '''
mkdir -p /var/lib/jenkins/gitcache/OMPackageManager
rm -f cache
ln -s /var/lib/jenkins/gitcache/OMPackageManager cache
'''
sh 'test -f rawdata.json'
sh './updateinfo.py'
sh './genindex.py'
stash name: 'files', includes: 'index.json, rawdata.json'
}
}
stage('upload') {
agent {
label 'linux'
}
when {
beforeAgent true
expression { params.UPLOAD_AND_CACHE }
}
environment {
HOME = '/tmp/dummy'
}
steps {
sshagent (credentials: ['Hudson-SSH-Key']) {
unstash 'files'
sh '''
git remote add github [email protected]:OpenModelica/OMPackageManager.git || true
git remote set-url github [email protected]:OpenModelica/OMPackageManager.git
'''
sh '''
git update-index --refresh || true
if ! ( git diff-index --quiet HEAD -- ); then
git config user.name "OpenModelica Jenkins"
git config user.email "[email protected]"
git commit -m "Updated libraries" rawdata.json
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git push github HEAD:master
fi
'''
}
sshPublisher(publishers: [sshPublisherDesc(configName: 'PackageIndex', transfers: [sshTransfer(sourceFiles: 'index.json', remoteDirectory: 'v1')])])
}
}
stage('cache') {
agent {
label 'r630-2'
}
when {
beforeAgent true
expression { params.UPLOAD_AND_CACHE }
}
environment {
HOME = '/tmp/dummy'
}
steps {
sh "du -csh /var/www/libraries.openmodelica.org/cache/* || true"
sh "cp /var/www/libraries.openmodelica.org/index/v1/index.json ."
sh "./generate-cache.py --clean /var/www/libraries.openmodelica.org/cache"
sh "du -csh /var/www/libraries.openmodelica.org/cache/*"
}
}
}
}