-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
124 lines (119 loc) · 3.83 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
pipeline {
agent {
kubernetes {
inheritFrom 'default'
containerTemplates([
containerTemplate(name: 'play', image: 'flowdocker/play_builder:latest-java17-jammy', command: 'cat', ttyEnabled: true),
])
}
}
options {
disableConcurrentBuilds()
}
stages {
stage('Checkout') {
steps {
checkoutWithTags scm
}
}
stage('SBT Test') {
when {
not { branch 'main' }
changeRequest()
}
steps {
container('play') {
script {
try {
sh '''
sbt clean coverage compile flowLintLib test scalafmtSbtCheck scalafmtCheck doc
sbt coverageAggregate
'''
} finally {
junit allowEmptyResults: true, testResults: '**/target/test-reports/*.xml'
step([$class: 'ScoveragePublisher', reportDir: 'target/scala-2.13/scoverage-report', reportFile: 'scoverage.xml'])
publishHTML (target : [allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'target/scala-2.13/scoverage-report',
reportFiles: 'index.html',
reportName: 'Scoverage Code Coverage',
reportTitles: 'Scoverage Code Coverage'])
}
}
}
}
}
stage('Commit auto-generated code') {
when { branch 'main' }
steps {
container('play') {
withCredentials([
usernamePassword(
credentialsId: 'jenkins-x-github',
usernameVariable: 'GIT_USERNAME',
passwordVariable: 'GIT_PASSWORD'
),
usernamePassword(
credentialsId: 'jenkins-x-jfrog',
usernameVariable: 'ARTIFACTORY_USERNAME',
passwordVariable: 'ARTIFACTORY_PASSWORD'
)
]) {
script {
sh '''
git config --global credential.helper "store --file=/tmp/git-credentials"
echo "https://$GIT_USERNAME:$GIT_PASSWORD@github.com" > /tmp/git-credentials
git config --global --add safe.directory $(pwd)
mkdir -p /root/.ssh
touch /root/.ssh/known_hosts
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
go run script/generate.go
sbt clean compile flowLintLib test scalafmtSbtCheck scalafmtCheck doc
'''
HAS_CHANGES = sh(script:'git commit -a -m "Update generated code"', returnStatus:true) == 0
println("Push to upstream? " + HAS_CHANGES)
if (HAS_CHANGES) {
sh '''
git push --set-upstream origin main
git push
'''
}
NEED_NEW_TAG = !new flowSemver().calculateSemver().isSameAsCurrentRepoTag
println("Need new tag? " + NEED_NEW_TAG)
}
}
}
}
}
stage('Release') {
when {
branch 'main'
expression { return NEED_NEW_TAG == true }
}
steps {
container('play') {
withCredentials([
usernamePassword(
credentialsId: 'jenkins-x-github',
usernameVariable: 'GIT_USERNAME',
passwordVariable: 'GIT_PASSWORD'
),
usernamePassword(
credentialsId: 'jenkins-x-jfrog',
usernameVariable: 'ARTIFACTORY_USERNAME',
passwordVariable: 'ARTIFACTORY_PASSWORD'
)
]) {
script {
VERSION = new flowSemver().calculateSemver()
new flowSemver().commitSemver(VERSION)
sh 'sbt clean +publish'
syncDependencyLibrary()
}
}
}
}
}
}
}