-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsFile
73 lines (65 loc) · 2.08 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
node {
def root = pwd()
def nodejs = tool 'NodeJS_6'
stage('Clean') {
deleteDir()
}
stage("Config") {
// clone the configuration repository and copy the current configuration
def configDir = "${root}/configuration"
def configFile = "${root}/config.json"
dir(configDir) {
git url: "${env.CONFIGURATION_URL}", credentialsId: "${env.CONFIGURATION_CREDS}"
sh "mv ${configDir}/${ENVIRONMENT}-config.json ${configFile}"
deleteDir()
}
// read the current configuration
def configJson = readJSON file: "${configFile}"
for (param in configJson.credparams + configJson.jobparams) {
env."${param.name}" = (param.type == "booleanParam") ? "${param.defaultvalue}".toBoolean() : "${param.defaultvalue}"
}
}
stage('Setup') {
git([
url: "https://github.com/venicegeo/pztest-integration",
poll: true,
branch: "master"
])
}
stage('Sync with GitLab') {
withCredentials([file(credentialsId: 'pztest-integration-key', variable: 'GIT_KEY')]) {
sh """
export HOME=\$(pwd)
# We need to use our own write-access key for this push to gitlab.
eval "\$(ssh-agent -s)"
if [ ! -f \$HOME/.ssh/config ]; then
mkdir -p \$HOME/.ssh
touch \$HOME/.ssh/config
fi
[ -f "\$GIT_KEY" ] && ssh-add "\$GIT_KEY"
chmod 600 \$HOME/.ssh/config
cat <<- EOF > \$HOME/.ssh/config
Host gitlab.devops.geointservices.io
HostName gitlab.devops.geointservices.io
User git
IdentityFile \$GIT_KEY
IdentitiesOnly yes
EOF
chmod 400 \$HOME/.ssh/config
git remote add gitlab [email protected]:venicegeo/pztest-integration-source.git
git push gitlab master
"""
}
}
stage('Test') {
withCredentials([file(credentialsId: "${env.POSTMAN_SECRET_FILE}", variable: 'POSTMAN_FILE')]) {
withEnv(["PATH+=${root}/node_modules/newman/bin:${nodejs}/bin", "PCF_SPACE=test", "HOME=${root}"]) {
sh "npm install newman@3"
sh "ci/blackbox.sh"
}
}
}
stage ('Cleanup') {
deleteDir()
}
}