This repository has been archived by the owner on Feb 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
124 lines (108 loc) · 6.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
pipeline {
agent {
node {
label 'team:nhgf'
}
}
stages {
stage('Set Build Description') {
steps {
script {
currentBuild.description = "Deploy to ${env.DEPLOY_STAGE}"
}
}
}
stage('Clean Workspace') {
steps {
cleanWs()
}
}
stage('Git Clone') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'CIDA-Jenkins-GitHub',
url: 'https://github.com/NWQMC/wmadata-schema-data-prep.git']]])
}
}
stage('Run geoserver config') {
steps {
script {
def nldiSecretsString = sh(script: '/usr/local/bin/aws ssm get-parameter --name "/aws/reference/secretsmanager/NLDI_$DEPLOY_STAGE" --query "Parameter.Value" --with-decryption --output text --region "us-west-2"', returnStdout: true).trim()
def iowGeoSecretsString = sh(script: '/usr/local/bin/aws ssm get-parameter --name "/aws/reference/secretsmanager/IOW-GEOSERVER" --query "Parameter.Value" --with-decryption --output text --region "us-west-2"', returnStdout: true).trim()
def nldiSecretsJson = readJSON text: nldiSecretsString
def iowGeoSecretsJson = readJSON text: iowGeoSecretsString
env.NWIS_DATABASE_ADDRESS = nldiSecretsJson.DATABASE_ADDRESS
env.NWIS_DATABASE_NAME = nldiSecretsJson.DATABASE_NAME
env.WMADATA_SCHEMA_NAME = nldiSecretsJson.WMADATA_SCHEMA_NAME
env.WMADATA_DB_READ_ONLY_USERNAME = nldiSecretsJson.WMADATA_DB_READ_ONLY_USERNAME
env.WMADATA_DB_READ_ONLY_PASSWORD = nldiSecretsJson.WMADATA_DB_READ_ONLY_PASSWORD
env.GEOSERVER_PASSWORD = iowGeoSecretsJson.admin
env.GEOSERVER_WORKSPACE = 'wmadata'
env.GEOSERVER_STORE = 'wmadata'
sh '''
if [ $DEPLOY_STAGE == "TEST" ]; then
url="https://labs-dev.wma.chs.usgs.gov/geoserver"
else
url="https://labs.waterdata.usgs.gov/geoserver"
fi
touch wmadata_store.xml
{
echo '<dataStore>
<name>'$GEOSERVER_STORE'</name>
<connectionParameters>
<host>'$NWIS_DATABASE_ADDRESS'</host>
<port>5432</port>
<database>'$NWIS_DATABASE_NAME'</database>
<schema>'$WMADATA_SCHEMA_NAME'</schema>
<user>'$WMADATA_DB_READ_ONLY_USERNAME'</user>
<passwd>'$WMADATA_DB_READ_ONLY_PASSWORD'</passwd>
<dbtype>postgis</dbtype>
</connectionParameters>
</dataStore>' > wmadata_store.xml
} 2> /dev/null
curl -v -u admin:$GEOSERVER_PASSWORD -XPOST -H "Content-type: text/xml" \
-d "<workspace><name>$GEOSERVER_WORKSPACE</name></workspace>" \
$url/rest/workspaces
curl -v -u admin:$GEOSERVER_PASSWORD -XPOST -T wmadata_store.xml -H "Content-type: text/xml" \
$url/rest/workspaces/$GEOSERVER_WORKSPACE/datastores
curl -v -u admin:$GEOSERVER_PASSWORD -XPOST -H "Content-type: text/xml" \
-d "<featureType><name>gagesii</name><nativeCRS>EPSG:4269</nativeCRS><srs>EPSG:4269</srs></featureType>" \
$url/rest/workspaces/$GEOSERVER_WORKSPACE/datastores/$GEOSERVER_STORE/featuretypes
curl -v -u admin:$GEOSERVER_PASSWORD -XPOST -H "Content-type: text/xml" \
-d "<featureType><name>huc08</name><nativeCRS>EPSG:4269</nativeCRS><srs>EPSG:4269</srs></featureType>" \
$url/rest/workspaces/$GEOSERVER_WORKSPACE/datastores/$GEOSERVER_STORE/featuretypes
curl -v -u admin:$GEOSERVER_PASSWORD -XPOST -H "Content-type: text/xml" \
-d "<featureType><name>huc12</name><nativeCRS>EPSG:4269</nativeCRS><srs>EPSG:4269</srs></featureType>" \
$url/rest/workspaces/$GEOSERVER_WORKSPACE/datastores/$GEOSERVER_STORE/featuretypes
curl -v -u admin:$GEOSERVER_PASSWORD -XPOST -H "Content-type: text/xml" \
-d "<featureType><name>huc12all</name><nativeCRS>EPSG:4269</nativeCRS><srs>EPSG:4269</srs></featureType>" \
$url/rest/workspaces/$GEOSERVER_WORKSPACE/datastores/$GEOSERVER_STORE/featuretypes
curl -v -u admin:$GEOSERVER_PASSWORD -XPOST -H "Content-type: text/xml" \
-d "<featureType><name>huc12agg</name><nativeCRS>EPSG:4269</nativeCRS><srs>EPSG:4269</srs></featureType>" \
$url/rest/workspaces/$GEOSERVER_WORKSPACE/datastores/$GEOSERVER_STORE/featuretypes
curl -v -u admin:$GEOSERVER_PASSWORD -XPOST -H "Content-type: text/xml" \
-d "<featureType><name>catchmentsp</name><nativeCRS>EPSG:4269</nativeCRS><srs>EPSG:4269</srs></featureType>" \
$url/rest/workspaces/$GEOSERVER_WORKSPACE/datastores/$GEOSERVER_STORE/featuretypes
curl -v -u admin:$GEOSERVER_PASSWORD -XPOST -H "Content-type: text/xml" \
-d "<featureType><name>nhdarea</name><nativeCRS>EPSG:4269</nativeCRS><srs>EPSG:4269</srs></featureType>" \
$url/rest/workspaces/$GEOSERVER_WORKSPACE/datastores/$GEOSERVER_STORE/featuretypes
curl -v -u admin:$GEOSERVER_PASSWORD -XPOST -H "Content-type: text/xml" \
-d "<featureType><name>nhdflowline_network</name><nativeCRS>EPSG:4269</nativeCRS><srs>EPSG:4269</srs></featureType>" \
$url/rest/workspaces/$GEOSERVER_WORKSPACE/datastores/$GEOSERVER_STORE/featuretypes
curl -v -u admin:$GEOSERVER_PASSWORD -XPOST -H "Content-type: text/xml" \
-d "<featureType><name>nhdflowline_nonnetwork</name><nativeCRS>EPSG:4269</nativeCRS><srs>EPSG:4269</srs></featureType>" \
$url/rest/workspaces/$GEOSERVER_WORKSPACE/datastores/$GEOSERVER_STORE/featuretypes
curl -v -u admin:$GEOSERVER_PASSWORD -XPOST -H "Content-type: text/xml" \
-d "<featureType><name>nhdwaterbody</name><nativeCRS>EPSG:4269</nativeCRS><srs>EPSG:4269</srs></featureType>" \
$url/rest/workspaces/$GEOSERVER_WORKSPACE/datastores/$GEOSERVER_STORE/featuretypes
'''
}
}
}
}
}