forked from oscript-library/packman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
106 lines (84 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
pipeline {
agent none
options {
buildDiscarder(logRotator(numToKeepStr: '7'))
skipDefaultCheckout()
}
stages {
stage('Тестирование кода пакета WIN') {
agent { label 'windows' }
steps {
checkout scm
script {
bat 'chcp 65001 > nul && opm install -l'
if( fileExists ('tasks/test.os') ){
try {
cmd("oscript tasks/test.os")
junit 'tests.xml'
} catch (Exception err) {
junit 'tests.xml'
throw err;
}
}
else
echo 'no testing task'
}
}
}
stage('Тестирование кода пакета LINUX') {
agent { label 'master' }
steps {
echo 'under development'
}
}
stage('Сборка пакета') {
agent { label 'windows' }
steps {
checkout scm
bat 'erase /Q *.ospx'
bat 'chcp 65001 > nul && call opm build .'
stash includes: '*.ospx', name: 'package'
archiveArtifacts '*.ospx'
}
}
stage('Публикация в хабе') {
when {
branch 'master'
}
agent { label 'master' }
steps {
sh 'rm -f *.ospx'
unstash 'package'
sh '''
artifact=`ls -1 *.ospx`
basename=`echo $artifact | sed -r 's/(.+)-.*(.ospx)/\\1/'`
cp $artifact $basename.ospx
sudo rsync -rv *.ospx /var/www/hub.oscript.io/download/$basename/
'''.stripIndent()
}
}
stage('Публикация в нестабильном хабе') {
when {
branch 'develop'
}
agent { label 'master' }
steps {
sh 'rm -f *.ospx'
unstash 'package'
sh '''
artifact=`ls -1 *.ospx`
basename=`echo $artifact | sed -r 's/(.+)-.*(.ospx)/\\1/'`
cp $artifact $basename.ospx
sudo rsync -rv *.ospx /var/www/hub.oscript.io/dev-channel/$basename/
'''.stripIndent()
}
}
}
}
def cmd(command) {
if (isUnix()) {
sh "${command}"
} else {
bat "chcp 65001\n${command}"
}
}