2019-02-16 04:16:49 +08:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
2019-02-21 01:22:05 +08:00
|
|
|
def gems = [
|
2019-02-26 00:14:35 +08:00
|
|
|
'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'
|
2019-02-21 01:22:05 +08:00
|
|
|
]
|
|
|
|
|
2019-02-26 00:14:35 +08:00
|
|
|
def withGerritCredentials = { Closure command ->
|
2019-02-28 23:53:11 +08:00
|
|
|
withCredentials([
|
|
|
|
sshUserPrivateKey(credentialsId: '44aa91d6-ab24-498a-b2b4-911bcb17cc35', keyFileVariable: 'SSH_KEY_PATH', usernameVariable: 'SSH_USERNAME')
|
|
|
|
]) { command() }
|
2019-02-21 01:22:05 +08:00
|
|
|
}
|
|
|
|
|
2019-03-02 01:10:21 +08:00
|
|
|
def fetchFromGerrit = { String repo, String path, String customRepoDestination = null, String sourcePath = '' ->
|
2019-02-28 23:53:11 +08:00
|
|
|
withGerritCredentials({ ->
|
2019-02-26 00:14:35 +08:00
|
|
|
sh """
|
|
|
|
mkdir -p ${path}/${customRepoDestination ?: repo}
|
|
|
|
GIT_SSH_COMMAND='ssh -i \"$SSH_KEY_PATH\" -l \"$SSH_USERNAME\"' \
|
2019-02-28 22:52:49 +08:00
|
|
|
git archive --remote=ssh://$GERRIT_URL/${repo} master ${sourcePath} | tar -x -C ${path}/${customRepoDestination ?: repo}
|
2019-02-26 00:14:35 +08:00
|
|
|
"""
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-02-21 01:22:05 +08:00
|
|
|
def fetchGems = gems.collectEntries { String gem ->
|
|
|
|
[ "${gem}" : { fetchFromGerrit(gem, 'gems/plugins') } ]
|
|
|
|
}
|
|
|
|
|
2019-02-22 10:23:12 +08:00
|
|
|
def getImageTag() {
|
|
|
|
//if (env.GERRIT_EVENT_TYPE == 'patchset-created') {
|
|
|
|
// GERRIT__REFSPEC will be in the form 'refs/changes/63/181863/8'
|
|
|
|
// we want a name in the form '63.181863.8'
|
|
|
|
NAME = "${env.GERRIT_REFSPEC}".minus('refs/changes/').replaceAll('/','.')
|
|
|
|
return "$DOCKER_REGISTRY_FQDN/jenkins/canvas-lms:$NAME"
|
|
|
|
//} else {
|
|
|
|
// return "$DOCKER_REGISTRY_FQDN/jenkins/canvas-lms:$GERRIT_BRANCH"
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
|
2019-02-16 04:16:49 +08:00
|
|
|
pipeline {
|
2019-02-21 01:06:06 +08:00
|
|
|
agent { label 'docker' }
|
2019-02-16 04:16:49 +08:00
|
|
|
|
2019-02-21 01:06:06 +08:00
|
|
|
options {
|
|
|
|
ansiColor('xterm')
|
2019-02-21 01:22:05 +08:00
|
|
|
parallelsAlwaysFailFast()
|
2019-02-21 01:06:06 +08:00
|
|
|
}
|
2019-02-20 23:41:00 +08:00
|
|
|
|
2019-02-21 01:06:06 +08:00
|
|
|
environment {
|
2019-02-21 01:22:05 +08:00
|
|
|
GERRIT_PORT = "29418"
|
|
|
|
GERRIT_URL = "$GERRIT_HOST:$GERRIT_PORT"
|
2019-02-22 10:23:12 +08:00
|
|
|
IMAGE_TAG = getImageTag()
|
2019-02-21 01:06:06 +08:00
|
|
|
}
|
2019-02-16 04:16:49 +08:00
|
|
|
|
2019-02-21 01:06:06 +08:00
|
|
|
stages {
|
2019-02-26 00:14:35 +08:00
|
|
|
stage('Debug') {
|
|
|
|
steps {
|
2019-02-28 09:05:41 +08:00
|
|
|
sh 'printenv | sort'
|
2019-02-26 00:14:35 +08:00
|
|
|
}
|
|
|
|
}
|
2019-02-21 01:22:05 +08:00
|
|
|
|
|
|
|
stage('Other Project Dependencies') {
|
|
|
|
parallel {
|
|
|
|
|
|
|
|
stage('Gems') {
|
|
|
|
steps { script { parallel fetchGems } }
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Vendor QTI Migration Tool') {
|
|
|
|
steps {
|
|
|
|
script {
|
2019-02-28 22:52:49 +08:00
|
|
|
withGerritCredentials({
|
|
|
|
fetchFromGerrit('qti_migration_tool', 'vendor', 'QTIMigrationTool')
|
2019-02-26 00:14:35 +08:00
|
|
|
})
|
2019-02-21 01:22:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Config Files') {
|
|
|
|
steps {
|
|
|
|
script {
|
2019-02-28 23:53:11 +08:00
|
|
|
withGerritCredentials({ ->
|
2019-02-28 22:52:49 +08:00
|
|
|
fetchFromGerrit('gerrit_builder', 'config', '', 'canvas-lms/config')
|
2019-02-26 00:14:35 +08:00
|
|
|
})
|
2019-02-21 01:22:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Build Image') {
|
2019-02-21 01:06:06 +08:00
|
|
|
steps {
|
|
|
|
timeout(time: 20, unit: 'MINUTES') {
|
2019-02-21 01:22:05 +08:00
|
|
|
sh 'docker build -t $IMAGE_TAG .'
|
2019-02-16 04:16:49 +08:00
|
|
|
}
|
2019-02-21 01:06:06 +08:00
|
|
|
}
|
|
|
|
}
|
2019-02-16 04:16:49 +08:00
|
|
|
|
2019-02-22 10:23:12 +08:00
|
|
|
stage("Publish Image") {
|
2019-02-21 01:06:06 +08:00
|
|
|
steps {
|
|
|
|
timeout(time: 5, unit: 'MINUTES') {
|
2019-02-21 01:22:05 +08:00
|
|
|
sh 'docker push $IMAGE_TAG'
|
2019-02-16 04:16:49 +08:00
|
|
|
}
|
2019-02-21 01:06:06 +08:00
|
|
|
}
|
2019-02-16 04:16:49 +08:00
|
|
|
}
|
2019-02-21 01:06:06 +08:00
|
|
|
}
|
2019-02-16 04:16:49 +08:00
|
|
|
}
|