-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
83 lines (79 loc) · 2.34 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
pipeline {
agent {
kubernetes {
yaml """
kind: Pod
metadata:
name: jenkins-agent
spec:
containers:
- name: jnlp
image: rahmnathan/inbound-agent
imagePullPolicy: Always
tty: true
volumeMounts:
- name: docker
mountPath: /var/run/docker.sock
volumes:
- name: docker
hostPath:
path: '/var/run/docker.sock'
"""
}
}
tools {
maven 'Maven'
jdk 'Java 21'
}
stages {
stage('Checkout') {
steps {
script {
git 'https://github.com/rahmnathan/rahmnathan-adapters.git'
}
}
}
stage('Set Version') {
steps {
script {
PROJECT_VERSION = sh(
script: "mvn help:evaluate -Dexpression=project.version -q -DforceStdout",
returnStdout: true
).trim()
env.NEW_VERSION = "${PROJECT_VERSION}.${BUILD_NUMBER}"
sh "mvn -DnewVersion='${NEW_VERSION}' versions:set"
}
}
}
stage('Tag') {
steps {
script {
sh 'git config --global user.email "rahm.nathan@protonmail.com"'
sh 'git config --global user.name "rahmnathan"'
sshagent(credentials: ['Github-Git']) {
sh 'mkdir -p /home/jenkins/.ssh'
sh 'ssh-keyscan github.com >> ~/.ssh/known_hosts'
sh "mvn -Dtag=${NEW_VERSION} scm:tag"
}
}
}
}
stage('Unit Test') {
steps {
sh 'mvn test'
}
}
stage('Package & Deploy Jar to Artifactory') {
steps {
script {
server = Artifactory.server 'Artifactory'
rtMaven = Artifactory.newMavenBuild()
rtMaven.tool = 'Maven'
rtMaven.deployer releaseRepo: 'rahmnathan-libraries', snapshotRepo: 'rahmnathan-libraries', server: server
buildInfo = Artifactory.newBuildInfo()
rtMaven.run pom: 'pom.xml', goals: 'install -DskipTests', buildInfo: buildInfo
}
}
}
}
}