-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathJenkinsfile
87 lines (76 loc) · 2.78 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
// pipeline {
// agent {
// docker {
// image 'haufelexware/wicked.build-agent:latest'
// // Add docker group
// args '--group-add 999'
// }
// }
// triggers {
// pollSCM "H/10 * * * *"
// upstream(upstreamProjects: "wicked.env/" + env.BRANCH_NAME.replaceAll("/", "%2F"), threshold: hudson.model.Result.SUCCESS)
// }
// stages {
// stage('SonarQube analysis') {
// steps {
// script {
// sh 'id'
// def dockerTag = env.BRANCH_NAME.replaceAll('/', '-')
// if (dockerTag == 'next') {
// // requires SonarQube Scanner 2.8+
// def scannerHome = tool 'wicked-sonar';
// withSonarQubeEnv('sonar') {
// sh "${scannerHome}/bin/sonar-scanner"
// }
// } else {
// echo 'Skipping SonarQube, not "next" branch.'
// }
// }
// }
// }
// stage('Build and Push') {
// steps {
// script {
// withCredentials([
// usernamePassword(credentialsId: 'dockerhub_wicked', usernameVariable: 'DOCKER_REGISTRY_USER', passwordVariable: 'DOCKER_REGISTRY_PASSWORD')
// ]) {
// env.DOCKER_TAG = env.BRANCH_NAME.replaceAll('/', '-')
// sh './build.sh --push'
// }
// }
// }
// }
// }
// }
properties([
pipelineTriggers([
[$class: "SCMTrigger", scmpoll_spec: "H/10 * * * *"],
[$class: 'jenkins.triggers.ReverseBuildTrigger', upstreamProjects: "wicked.env/" + env.BRANCH_NAME.replaceAll("/", "%2F"), threshold: hudson.model.Result.SUCCESS]
])
])
node('docker') {
stage('Checkout') {
checkout scm
}
def dockerTag = env.BRANCH_NAME.replaceAll('/', '-')
echo 'Building docker tag: ' + dockerTag
env.DOCKER_TAG = dockerTag
// stage('SonarQube analysis') {
// if (dockerTag == 'next') {
// // requires SonarQube Scanner 2.8+
// def scannerHome = tool 'wicked-sonar';
// withSonarQubeEnv('sonar') {
// sh "${scannerHome}/bin/sonar-scanner"
// }
// } else {
// echo 'Skipping SonarQube, not "next" branch.'
// }
// }
stage('Build and Push') {
withCredentials([
usernamePassword(credentialsId: 'dockerhub_wicked', usernameVariable: 'DOCKER_REGISTRY_USER', passwordVariable: 'DOCKER_REGISTRY_PASSWORD')
]) {
sh './build.sh --push'
}
}
}