-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
62 lines (56 loc) · 2.33 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
node {
try {
stage ('Checkout Scm') {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github', url: 'https://github.com/kavaka123/alpha-blog.git']]])
}
stage('SonarQube coverage for unit/integration tests') {
def scannerHome = tool 'sonar_scanner';
withSonarQubeEnv() {
sh "bundle install --path vendor/bundle"
sh "bundle exec rake test"
junit keepLongStdio: true, testResults: '**/test/reports/*.xml'
sh "${scannerHome}/bin/sonar-scanner"
}
}
stage('Archive tar file and upload to artifactory') {
sh "touch ${JOB_NAME}${BUILD_ID}.tar.gz"
sh "tar --exclude ./.bundle --exclude ./vendor --exclude ./tmp --exclude ./.git --exclude ./log --exclude ./db/*.sqlite3 --exclude *.tar.gz -czf ${JOB_NAME}${BUILD_ID}.tar.gz ."
archiveArtifacts artifacts: '*.tar.gz', onlyIfSuccessful: true
def server = Artifactory.server 'local-artifactory-server'
server.credentialsId = 'jenkins'
def buildInfo = Artifactory.newBuildInfo()
def uploadSpec = """{
"files": [
{
"pattern": "./*.tar.gz",
"target": "alpha-blog-local/"
}
]
}"""
server.upload spec: uploadSpec, buildInfo: buildInfo, failNoOp: true
server.publishBuildInfo buildInfo
}
// Commenting below code as build promotion is only availble in artifactory pro
// stage('Promote Build in artifactory') {
// def server = Artifactory.server 'local-artifactory-server'
// server.credentialsId = 'jenkins'
// def buildInfo = Artifactory.newBuildInfo()
// def promotionConfig = [
// 'targetRepo' : 'alpha-blog-prod',
// 'buildName' : buildInfo.name,
// 'buildNumber' : buildInfo.number,
// 'comment' : 'This is the promotion comment',
// 'status' : 'Released',
// 'sourceRepo' : 'alpha-blog-local',
// 'copy' : true,
// 'failFast' : true
// ]
// server.promote promotionConfig
// }
} finally {
stage ('Cleanup workspace') {
echo "Cleaning up workspace in jenkins home dir"
cleanWs()
}
}
}