-
Notifications
You must be signed in to change notification settings - Fork 23
/
Jenkinsfile
66 lines (62 loc) · 1.9 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
def projectProperties = [
[$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '3']],
]
properties(projectProperties)
pipeline {
agent any
stages {
stage('Cleanup') {
steps {
withMaven(maven: 'maven-3.2.5') {
sh 'mvn clean'
}
}
}
stage('Test') {
steps {
withMaven(maven: 'maven-3.2.5') {
sh 'mvn test'
}
}
}
stage('Compile') {
steps {
withMaven(maven: 'maven-3.2.5') {
sh 'mvn compile'
}
}
}
stage('Package') {
steps {
withMaven(maven: 'maven-3.2.5') {
sh 'mvn package'
}
}
}
stage('Notify') {
steps {
echo 'Build Successful!'
}
}
stage('Integration Tests') {
steps {
sh 'curl -o vault.zip https://releases.hashicorp.com/vault/0.7.0/vault_0.7.0_linux_arm.zip ; yes | unzip vault.zip'
withCredentials([string(credentialsId: 'role', variable: 'ROLE_ID'),string(credentialsId: 'VAULTTOKEN', variable: 'VAULT_TOKEN')]) {
sh '''
set -x
curl https://raw.githubusercontent.com/ncorrare/vault-java-example/master/ca.crt > ca.crt
export VAULT_CACERT=$(pwd)/ca.crt
export VAULT_ADDR=https://vault.service.lhr.consul:8200
export SECRET_ID=$(./vault write -field=secret_id -f auth/approle/role/java-example/secret-id)
export VAULT_TOKEN=$(./vault write -field=token auth/approle/login role_id=${ROLE_ID} secret_id=${SECRET_ID})
keytool -import -trustcacerts -file ca.crt -alias CorrarelloCA -keystore cacerts -noprompt -keypass changeit -storepass changeit
java -D"javax.net.ssl.trustStore=./cacerts" -jar target/java-client-example-1.0-SNAPSHOT-jar-with-dependencies.jar
'''
}
}
}
}
environment {
mvnHome = 'maven-3.2.5'
}
}