-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
61 lines (61 loc) · 1.96 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
pipeline {
agent any
// Global tools to be used by the pipeline
tools {
// Global tools to be used by the pipeline
maven 'jenkins-maven'
//jdk 'jdk8'
}
stages {
stage('Unit Tests') {
// Run Unit tests
steps{
sh 'mvn -f pom.xml clean test'
}
}
stage ('Artifactory configuration') {
steps {
// specify Artifactory server
rtServer (
id: "ARTIFACTORY_SERVER",
url: "http://artifactory:8081/artifactory",
credentialsId: 'adminJfrog'
)
// specify the repositories to be used for deploying the artifacts in the Artifactory
rtMavenDeployer (
id: "MAVEN_DEPLOYER",
serverId: "ARTIFACTORY_SERVER",
releaseRepo: "libs-release-local",
snapshotRepo: "libs-snapshot-local"
)
// defines the dependencies resolution details
rtMavenResolver (
id: "MAVEN_RESOLVER",
serverId: "ARTIFACTORY_SERVER",
releaseRepo: "libs-release",
snapshotRepo: "libs-snapshot"
)
}
}
stage ('Build & Upload Artifact') {
// run Maven Build and upload the built artifact to Artifactory
steps {
rtMavenRun (
tool: "jenkins-maven", // Tool name from Jenkins configuration
pom: 'pom.xml',
goals: 'clean install',
deployerId: "MAVEN_DEPLOYER",
resolverId: "MAVEN_RESOLVER"
)
}
}
stage ('Publish build info') {
// Publish the build info in the Artifactory
steps {
rtPublishBuildInfo (
serverId: "ARTIFACTORY_SERVER"
)
}
}
}
}