-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
92 lines (86 loc) · 2.88 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
pipeline {
agent {
dockerfile {
filename 'DevOps/Dockerfile_jenkins'
args '-u root:sudo'
}
}
stages {
stage('Init') {
steps {
sh 'echo "Inizio a buildare Hackubau Docx: $BUILD_TAG --name jdk8-mvn-node-fly-ans"'
}
}
stage('Build') {
steps {
sh 'mvn clean package -DskipTests'
sh 'zip -r sql.zip sql'
sh 'zip -r DevOps.zip DevOps'
archiveArtifacts(artifacts: 'target\\*.jar', onlyIfSuccessful: true)
archiveArtifacts(artifacts: 'pom.xml', onlyIfSuccessful: true)
archiveArtifacts(artifacts: 'src\\main\\resources\\*', onlyIfSuccessful: true)
archiveArtifacts(artifacts: 'sql.zip', onlyIfSuccessful: true)
archiveArtifacts(artifacts: 'DevOps.zip', onlyIfSuccessful: true)
}
}
stage('Test') {
steps {
warnError(message: 'Errore nei test - release instabile') {
sh 'mvn surefire-report:report'
junit 'target/surefire-reports/*.xml'
}
}
}
stage('Build Docker') {
steps {
sh 'echo "docker build . --tag hck:$BUILD_NUMBER"'
sh 'echo "docker run hck:$BUILD_NUMBER"'
sh 'echo "docker login -u mguassone -p qqQQ11!! localhost:8081/docker-hck"'
sh 'echo "docker push hck:$BUILD_NUMBER"'
}
}
stage('Manual Approvation') {
steps {
input 'Procedi al deploy in quality?'
}
}
stage('Nexus Upload') {
steps {
nexusArtifactUploader(nexusVersion: 'nexus3', protocol: 'http',
nexusUrl: 'localhost:8081/repository/hck',
groupId: 'it.hackubau',
version: '${BUILD_NUMBER}', repository: 'hck',
credentialsId: '4dfa3a50-c33c-4539-bc7f-b4e5558c056d',
artifacts: [
[ artifactId: 'hackubau-docs',
classifier: '',
file: "target/hackubau-docs-1.0-RELEASE.jar",
type: 'jar'],
[ artifactId: 'hackubau-docs_sql_migration',
classifier: '',
file: "sql.zip",
type: 'zip'],
[ artifactId: 'hackubau_docs_DevOps',
classifier: '',
file: "DevOps.zip",
type: 'zip']
])
}
}
stage('Database migration') {
steps {
sh 'flyway -configFiles=DevOps/flyway.conf -locations=filesystem:sql migrate'
}
}
stage('Deploy with ansible') {
steps {
ansiblePlaybook(playbook: 'DevOps/playbook.yml', inventory: 'DevOps/hosts')
}
}
}
environment {
NEXUS_URL='172.17.0.1:8081'
FLYWAY_URL = 'jdbc:sqlserver://172.17.0.1:1433;DatabaseName=bau'
ENV_QUALIFIER = 'dev'
}
}