forked from tonnyatresolve/banking-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-new
103 lines (92 loc) · 4.13 KB
/
Jenkinsfile-new
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
node {
def server
def rtMaven
def buildInfo
stage ('Git checkout') {
git url: 'https://github.com/tonnyatresolve/test-frog-notification.git'
}
stage ('Push to artifactory') {
// env.JAVA_HOME = '/opt/jdk-15.0.2'
// Obtain an Artifactory server instance, defined in Jenkins --> Manage Jenkins --> Configure System:
server = Artifactory.server 'jfartifactory'
rtMaven = Artifactory.newMavenBuild()
// Tool name from Jenkins configuration
rtMaven.tool = 'Maven3.6.3'
rtMaven.deployer releaseRepo: 'test-maven', snapshotRepo: 'test-maven', server: server
//rtMaven.deployer releaseRepo: 'test-maven-virtual', snapshotRepo: 'test-maven-virtual', server: server
rtMaven.resolver releaseRepo: 'test-maven-virtual', snapshotRepo: 'test-maven-virtual', server: server
buildInfo = Artifactory.newBuildInfo()
// Exec Maven
rtMaven.run pom: 'pom.xml', goals: 'clean install', buildInfo: buildInfo
//rtMaven.run pom: 'pom.xml', goals: 'deploy', buildInfo: buildInfo
// Publish build info
server.publishBuildInfo buildInfo
}
stage ('Xray artifactory scan') {
try {
def scanConfig = [
'buildName' : buildInfo.name,
'buildNumber' : buildInfo.number,
'failBuild' : true
]
def scanResult = server.xrayScan scanConfig
echo scanResult as String
} catch(error) {
echo "First build failed, let's retry if accepted"
retry(2) {
input "Violation found, retry the scan?"
def scanConfig = [
'buildName' : buildInfo.name,
'buildNumber' : buildInfo.number,
'failBuild' : true
]
def scanResult = server.xrayScan scanConfig
echo scanResult as String
}
}
}
stage ('Deploy') {
echo "Deploy"
}
/*
stage ('Build Docker') {
sh 'docker pull openjdk:21-jdk'
sh 'docker tag openjdk:21-jdk 192.168.11.60:8082/test-docker/openjdk:21-jdk'
//def server = Artifactory.server 'docker2'
// Step 2: Create an Artifactory Docker instance:
def rtDocker = Artifactory.docker server: server
// Or if the docker daemon is configured to use a TCP connection:
// def rtDocker = Artifactory.docker server: server, host: "tcp://<docker daemon host>:<docker daemon port>"
// If your agent is running on OSX:
// def rtDocker= Artifactory.docker server: server, host: "tcp://127.0.0.1:1234"
// Step 3: Push the image to Artifactory.
// Make sure that <artifactoryDockerRegistry> is configured to reference <targetRepo> Artifactory repository. In case it references a different repository, your build will fail with "Could not find manifest.json in Artifactory..." following the push.
def dockerBuildInfo = rtDocker.push '192.168.11.60:8082/test-docker/openjdk:21-jdk', 'openjdk:21-jdk'
// Step 4: Publish the build-info to Artifactory:
server.publishBuildInfo dockerBuildInfo
}
stage ('Xray docer scan') {
try {
def scanConfig = [
'buildName' : dockerBuildInfo.name,
'buildNumber' : dockerBuildInfo.number,
'failBuild' : true
]
def scanResult = server.xrayScan scanConfig
echo scanResult as String
} catch(error) {
echo "First build failed, let's retry if accepted"
retry(2) {
input "Retry the job ?"
def scanConfig = [
'buildName' : buildInfo.name,
'buildNumber' : buildInfo.number,
'failBuild' : true
]
def scanResult = server.xrayScan scanConfig
echo scanResult as String
}
}
}
*/
}