forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
120 lines (106 loc) · 3.14 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
#!/usr/bin/env groovy
def gems = [
'analytics',
'banner_grade_export_plugin',
'canvas_geoip',
'canvas_salesforce_plugin',
'canvas_webhooks',
'canvas_zendesk_plugin',
'canvasnet_registration',
'catalog_provisioner',
'custom_reports',
'demo_site',
'ims_es_importer_plugin',
'instructure_misc_plugin',
'migration_tool',
'multiple_root_accounts',
'phone_home_plugin',
'respondus_lockdown_browser',
'uuid_provisioner'
]
def withGerritCredentials = { Closure command ->
withCredentials([sshUserPrivateKey(credentialsId: '44aa91d6-ab24-498a-b2b4-911bcb17cc35', keyFileVariable: 'SSH_KEY_PATH', usernameVariable: 'SSH_USERNAME')]) {
command('$SSH_KEY_PATH', '$SSH_USERNAME')
}
}
def fetchFromGerrit = { String repo, String path, String customRepoDestination = null ->
withGerritCredentials({ String SSH_KEY_PATH, String SSH_USER_NAME ->
sh """
mkdir -p ${path}/${customRepoDestination ?: repo}
GIT_SSH_COMMAND='ssh -i \"$SSH_KEY_PATH\" -l \"$SSH_USERNAME\"' \
git archive --remote=ssh://$GERRIT_URL/${repo} master | tar -x -C ${path}/${customRepoDestination ?: repo}
"""
})
}
def fetchGems = gems.collectEntries { String gem ->
[ "${gem}" : { fetchFromGerrit(gem, 'gems/plugins') } ]
}
pipeline {
agent { label 'docker' }
options {
ansiColor('xterm')
parallelsAlwaysFailFast()
}
environment {
NAME = "${env.GERRIT_REFSPEC}".minus('refs/changes/').replaceAll('/','.')
IMAGE_TAG = "$DOCKER_REGISTRY_FQDN/canvas-lms:$NAME"
GERRIT_PORT = "29418"
GERRIT_URL = "$GERRIT_HOST:$GERRIT_PORT"
}
stages {
stage('Debug') {
steps {
sh 'printenv'
}
}
stage('Other Project Dependencies') {
parallel {
stage('Gems') {
steps { script { parallel fetchGems } }
}
stage('Vendor QTI Migration Tool') {
steps {
script {
withGerritCredentials({ String SSH_KEY_PATH, String SSH_USER_NAME ->
sh """
mkdir -p vendor/QTIMigrationTool
GIT_SSH_COMMAND='ssh -i \"$SSH_KEY_PATH\" -l \"$SSH_USERNAME\"' \
git archive --remote=ssh://$GERRIT_URL/qti_migration_tool master | tar -x -C vendor/QTIMigrationTool
"""
})
}
}
}
stage('Config Files') {
steps {
script {
withGerritCredentials({ String SSH_KEY_PATH, String SSH_USER_NAME ->
sh """
GIT_SSH_COMMAND='ssh -i \"$SSH_KEY_PATH\" -l \"$SSH_USERNAME\"' \
git archive --remote=ssh://$GERRIT_URL/gerrit_builder master canvas-lms/config | tar -x -C config
"""
})
}
}
}
}
}
stage('Build Image') {
steps {
timeout(time: 20, unit: 'MINUTES') {
sh 'docker build -t $IMAGE_TAG .'
}
}
}
/*
stage('Publish Image') {
when { environment name: 'GERRIT_EVENT_TYPE', value: 'change-merged' }
steps {
timeout(time: 5, unit: 'MINUTES') {
sh 'docker push $IMAGE_TAG'
}
}
}
*/
}
}