-
Notifications
You must be signed in to change notification settings - Fork 10
/
Jenkinsfile
63 lines (54 loc) · 1.98 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
@Library('velox') _
veloxPipeline { p ->
def server = Artifactory.server 'na-artifactory'
def rtDocker = Artifactory.docker server: server, credentialsId: 'slnode-artifactory'
def buildInfo = Artifactory.newBuildInfo()
def releaseName = env.CHANGE_ID ? env.CHANGE_TARGET : env.BRANCH_NAME
def tag = sh(returnStdout: true, script: "git tag --contains | head -1").trim()
def chartArchive
p.branch(~/main|\d+(\.\d+)+/) {
env.ARTIFACTS_DIR = "na.artifactory.swg-devops.com/artifactory/apic-monitoring"
// set the primary build identifiers
buildInfo.setName "trawler-${releaseName}"
buildInfo.setNumber currentBuild.id
// For easier referencing by other Jenkins builds/jobs
env.ARTIFACTS_BUILD = "${buildInfo.name}/${buildInfo.number}"
}
if (tag) {
env.DOCKER_TAG = "${tag}"
} else {
env.DOCKER_TAG = "build${currentBuild.id}"
}
env.DOCKER_IMAGE = "${env.DOCKER_REPO}/velox/${env.BRANCH_NAME}/trawler"
p.common {
stage('install dependencies') {
sh 'pip3 install setuptools'
sh 'pip3 install -r requirements-dev.txt'
sh 'pip3 install --user -r requirements.txt'
}
stage('Run tests') {
sh 'SECRETS=test-assets coverage run --source . -m py.test || echo 0'
sh 'coverage xml'
}
stage('SonarQube Code Analysis') {
if (env.BRANCH_NAME == "main") {
try {
runSonarScanner()
} catch (e) {
}
}
}
if (env.BRANCH_NAME ==~ /^PR-[0-9]*/) {
echo "Skipping publish for PR build"
currentBuild.result = 'SUCCESS'
return
}
stage('build trawler image') {
sh 'docker build -t $DOCKER_IMAGE:$DOCKER_TAG -t $DOCKER_IMAGE:latest . '
}
img = docker.image(env.DOCKER_IMAGE)
stage('push image') {
img.push()
}
}
}