forked from tmobile/jazz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
48 lines (39 loc) · 1.7 KB
/
Copy pathJenkinsfile
File metadata and controls
48 lines (39 loc) · 1.7 KB
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
#!groovy
import groovy.json.JsonOutput
import groovy.transform.Field
// To be replaced as @Field def repo_credential_id = "value" for repo_credential_id, repo_base and repo_core
@Field def repo_credential_id
@Field def repo_base
@Field def repo_core
@Field def scm_type
@Field def config_loader
/*
* Load environment variables from build module
*/
def loadConfigModule(build_module_url){
dir('config-loader') {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: repo_credential_id, url: build_module_url]]])
def result_json_string = readFile("jazz-installer-vars.json")
config_module = load "config-loader.groovy"
config_loader = config_module.initialize(result_json_string)
}
}
node {
loadConfigModule(getBuildModuleUrl())
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: config_loader.JENKINS.CREDENTIAL_ID, passwordVariable: 'PWD',
usernameVariable: 'UNAME']]){
echo "Build triggered via branch::${env.BRANCH_NAME}"
echo "params : $params"
def build_job = config_loader.LAMBDA.LAMBDA_BUILD_URI
def job_url = JenkinsLocationConfiguration.get().getUrl() + build_job
sh "curl -X GET -k -v -u \"$UNAME:$PWD\" \"" + job_url + "&service_name={service_name}&domain={domain}&scm_branch=${env.BRANCH_NAME}\""
}
}
def getBuildModuleUrl() {
if (scm_type && scm_type != "bitbucket") {
// right now only bitbucket has this additional tag scm in its git clone path
return "http://${repo_base}/${repo_core}/jazz-build-module.git"
}else {
return "http://${repo_base}/scm/${repo_core}/jazz-build-module.git"
}
}