-
Notifications
You must be signed in to change notification settings - Fork 5
/
Jenkinsfile
109 lines (104 loc) · 4.71 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
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('Tag new version') {
when { branch 'main' }
steps {
script {
VERSION = new flowSemver().calculateSemver()
new flowSemver().commitSemver(VERSION)
}
}
}
stage('SBT Test') {
steps {
container('play') {
script {
try {
sh '''
sbt clean coverage compile test scalafmtSbtCheck scalafmtCheck doc assembly
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('SBT Publish') {
when { branch 'main' }
steps {
container('play') {
withAWS(roleAccount: '479720515435', role: 'jenkins-build') {
withCredentials([
usernamePassword(
credentialsId: 'jenkins-x-github',
usernameVariable: 'GIT_USERNAME',
passwordVariable: 'GIT_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 /home/jenkins/workspace
git clone https://github.com/flowcommerce/aws-s3-public.git aws-s3-public
'''
sh '''
cd aws-s3-public
git checkout main &&
git pull --rebase &&
git fetch --tags origin
ls
pwd
'''
sh '''
sbt scalafmtSbtCheck scalafmtCheck clean assembly
cp ./target/scala-2.13/api-build-assembly-*.jar ./aws-s3-public/util/api-build/
cp ./target/scala-2.13/api-build-assembly-*.jar ./aws-s3-public/util/api-build/api-build.jar
'''
sh '''
cd aws-s3-public
git add util/api-build/*
if git diff --cached --exit-code --quiet
then
echo 'Nothing to commit, not git-pushing nor s3-syncing.' >&2
else
git commit -m 'Add new version of api-build' util/api-build
git push origin main
aws s3 sync util s3://io.flow.aws-s3-public/util --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers
fi
'''
syncDependencyLibrary()
}
}
}
}
}
}
}
}