-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
142 lines (121 loc) · 4.19 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env groovy
properties([
buildDiscarder(logRotator(numToKeepStr: '20'))
])
node('linux') {
def err = null
def appVersion = '0.0.0'
def artifactVersion = '0.0.0'
def archiveName = 'opensphere.zip'
def project_dir = 'opensphere-plugin-geoint-viewer'
def workspace_project = 'opensphere-yarn-workspace'
def workspace_project_branch = 'nga-workspace'
def workspace_dir = "${workspace_project}/workspace"
try {
stage('init') {
initEnvironment()
}
docker.withRegistry(env.DOCKER_REGISTRY, env.DOCKER_CREDENTIAL) {
def dockerImage = docker.image(env.DOCKER_IMAGE)
dockerImage.pull()
//
// - Disable user namespace for the container so permissions will map properly with the host
// - Set HOME to the workspace for cache/config directories (npm/yarn, mvn, etc)
//
dockerImage.inside("--userns=host -e HOME=${env.WORKSPACE}") {
stage('scm') {
sh "rm -rf ${workspace_project}"
try {
beforeCheckout()
} catch (NoSuchMethodError e) {
}
cloneProject(workspace_project, null, false, workspace_project_branch)
dir(workspace_dir) {
def projects = [
'opensphere',
'opensphere-nga-lib',
'opensphere-plugin-analyze',
'opensphere-plugin-geopackage',
'gv.config',
project_dir
]
for (def project in projects) {
cloneProject(project)
}
dir(project_dir) {
appVersion = version.getAppVersion()
artifactVersion = version.getArtifactVersion()
archiveName = "opensphere-${appVersion}.zip"
echo "App version: ${appVersion}"
echo "Artifact version: ${artifactVersion}"
}
}
}
dir(workspace_dir) {
stage('yarn') {
sh 'yarn config list'
sh "rm yarn.lock || true"
sh "closure_library_url=http://github.com/google/closure-library/archive/v20220803.zip closure_compiler_url=http://github.com/google/closure-compiler/archive/v20220803.zip yarn"
}
stage('build') {
dir('opensphere') {
sh 'yarn build'
}
}
stage('package') {
dir('opensphere') {
dir('dist') {
sh "zip -q -r ${archiveName} opensphere"
}
try {
// newer Jenkins
archiveArtifacts 'dist/*.zip'
archiveArtifacts '.build/opensphere.min.js.map'
} catch (NoSuchMethodError e) {
// older Jenkins
archive 'dist/*.zip'
archive '.build/opensphere.min.js.map'
}
}
}
stage('publish') {
if (env.NEXUS_CREDENTIAL && env.NEXUS_REPO && env.NEXUS_URL) {
withEnv(["HOME=${pwd()}", "_JAVA_OPTIONS=-Duser.home=${pwd()}"]) {
def mavenSettings = maven.generateMavenSettingsXmlFile(env.NEXUS_CREDENTIAL)
sh "cat ${mavenSettings}"
sh "mkdir -p .m2"
sh "mv ${mavenSettings} .m2/settings.xml"
dir('gv.config') {
def archivePath = "../opensphere/dist/${archiveName}"
def nexusUrl = "${env.NEXUS_URL}/repository/${env.NEXUS_REPO}"
sh "./publish.sh '${nexusUrl}' '${archivePath}' ${artifactVersion} opensphere"
}
}
} else {
echo 'Publish not configured, skipping.'
}
}
}
}
}
if (deployEnv.isDev() && env.DEPLOY_JOB) {
// Deploy the artifact when building on dev.
build job: "${env.DEPLOY_JOB}",
parameters: [string(name: 'ARTIFACT_VERSION', value: artifactVersion)],
quietPeriod: 5,
wait: false
}
} catch (e) {
currentBuild.result = 'FAILURE'
err = e
} finally {
try {
notifyBuild()
} catch (NoSuchMethodError e) {
error 'Please define "notifyBuild()" through a shared pipeline library for this network'
}
if (err) {
throw err
}
}
}