-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJenkinsfile
More file actions
65 lines (64 loc) · 1.9 KB
/
Jenkinsfile
File metadata and controls
65 lines (64 loc) · 1.9 KB
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
#!/usr/bin/env groovy
pipeline {
agent {
label 'maven-agent' // Use Jenkins node with this label
}
tools {
maven 'Maven' // Use the maven automatic installation configured in Jenkins
}
environment {
MVN_CMD = 'mvn -s /etc/m2/settings.xml --batch-mode' // Define the base Maven command
APP_NAME = 'bitrepository' // Application Name (Must match ArgoCD)
AUTH_TOKEN = 'TOKEN' // Authentication token for ArgoCD
}
options {
disableConcurrentBuilds() // Prevent concurrent builds
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Mvn clean package') {
steps {
sh "${env.MVN_CMD} -PallTests clean package"
}
}
stage('Analyze build results') {
steps {
recordIssues aggregatingResults: true, tools: [
java(),
javaDoc(),
mavenConsole(),
taskScanner(
highTags: 'FIXME',
normalTags: 'TODO',
includePattern: '**/*.java',
excludePattern: 'target/**/*'
)
]
}
}
stage('Push to Nexus (if Master)') {
steps {
script {
if (env.BRANCH_NAME == 'master') {
echo "Deploying '${env.BRANCH_NAME}' branch to Nexus"
sh "${env.MVN_CMD} clean deploy -DskipTests=true"
}
}
}
}
}
post {
success {
script {
echo 'Build succeeded, syncing application in ArgoCD.'
}
}
failure {
echo 'Build failed, investigate errors in the console output.'
}
}
}