forked from sakaiproject/sakai-translations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
76 lines (66 loc) · 2.17 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
properties([[$class: 'BuildDiscarderProperty',
strategy: [$class: 'LogRotator', numToKeepStr: '5']],
pipelineTriggers([cron('@midnight')]),
])
node {
// Clean the workspace
stage ('Cleanup') {
step([$class: 'WsCleanup'])
}
// First checkout the code
stage ('Checkout') {
// Checkout the source from sakai-translations.
checkout scm
// Checkout code from sakai repository
dir('sakai') {
git ( [url: 'https://github.com/sakaiproject/sakai.git', branch: env.BRANCH_NAME] )
}
// Move files inside sakai/l10n folder to work properly
dir('.') {
sh 'rm -rf sakai/l10n'
sh 'mkdir sakai/l10n'
sh 'cp l10n/* sakai/l10n/.'
}
}
// Read properties after checkout
def props = readProperties file: 'translation.properties'
def transifex_project = props['PROJECTNAME']
def locales = props['LOCALES'].split(',')
// Now run init transifex
stage ('Init Transifex') {
env.TRANSIFEX_SAKAI_PROJECTNAME=transifex_project
dir ('sakai/l10n') {
sh 'echo -e "\n" | python tmx.py init'
}
}
// Now upload translations to transifex
stage ('Upload Translations') {
env.TRANSIFEX_SAKAI_PROJECTNAME=transifex_project
dir ('sakai/l10n') {
sh "python tmx.py update --java2po"
sh "python tmx.py upload -m -v"
}
}
// Now download translations from transifex
stage ('Download Translations') {
env.TRANSIFEX_SAKAI_PROJECTNAME=transifex_project
dir ('sakai') {
for (int i=0; i<locales.size(); i++) {
sh "cd l10n;python tmx.py download -r -u -c -l ${locales[i]};cd .."
sh "git add -N '*_${locales[i]}.properties'"
sh "git diff --ignore-space-at-eol -- '*_${locales[i]}.properties' > ../translation_${locales[i]}.patch"
}
}
}
stage ('Publish Patches') {
for (int i=0; i<locales.size(); i++) {
publishHTML(
[allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: false,
reportDir: '.',
reportFiles: 'translation_' + locales[i] + '.patch',
reportName: 'TranslationPatch_' + locales[i] ])
}
}
}