1
+ // Jenkinsfilek8s v1.2.0
2
+
1
3
pipeline {
2
4
agent {
3
5
kubernetes {
@@ -13,7 +15,8 @@ pipeline {
13
15
description: "Email to send build failure and fixed notifications.")
14
16
}
15
17
16
- environment {
18
+ environment {
19
+ GITHUB_OWNER = 'microchip-pic-avr-examples'
17
20
GITHUB_URL ='https://github.com/microchip-pic-avr-examples/atmega4809-noise-countermeasures-adc-mplab.git'
18
21
BITBUCKET_URL = 'https://bitbucket.microchip.com/scm/ebe/atmega4809-noise-countermeasures-adc-mplab.git'
19
22
DEPLOY_TOOL_URL = 'https://bitbucket.microchip.com/scm/citd/tool-github-deploy.git'
@@ -23,7 +26,7 @@ pipeline {
23
26
24
27
options {
25
28
timestamps()
26
- timeout(time: 20 , unit: 'MINUTES')
29
+ timeout(time: 30 , unit: 'MINUTES')
27
30
}
28
31
29
32
stages {
@@ -33,6 +36,17 @@ pipeline {
33
36
}
34
37
}
35
38
39
+ stage('metadata') {
40
+ steps {
41
+ script {
42
+ execute("pip install jsonschema")
43
+ execute("git clone https://bitbucket.microchip.com/scm/citd/metadata-schema.git")
44
+ execute("git clone https://bitbucket.microchip.com/scm/citd/tool-metadata-validator.git")
45
+ execute("cd tool-metadata-validator && python metadata-validator.py -data '../.main-meta/main.json' -schema '../metadata-schema/main-schema.json'")
46
+ }
47
+ }
48
+ }
49
+
36
50
stage('Pre-build') {
37
51
steps {
38
52
script {
@@ -56,7 +70,7 @@ pipeline {
56
70
}
57
71
}
58
72
59
- stage('Deploy') {
73
+ stage('GitHub- Deploy') {
60
74
when {
61
75
not {
62
76
changeRequest()
@@ -76,8 +90,40 @@ pipeline {
76
90
sendSuccessfulGithubDeploymentEmail()
77
91
}
78
92
}
79
- }
93
+ }
94
+
95
+ stage('Portal-Deploy') {
96
+ when {
97
+ not {
98
+ changeRequest()
99
+ }
100
+ tag ''
101
+ }
102
+ steps {
103
+ script {
104
+ def metadata = readJSON file:".main-meta/main.json"
105
+ def version = metadata.content.version
106
+ def project = metadata.content.projectName
107
+
108
+ if(version == env.TAG_NAME) {
109
+ def cmdArgs = "'{\"repoOwnerName\":\"$env.GITHUB_OWNER\",\"repoName\":\"$project\",\"tagName\":\"$version\"}'"
110
+ cmdArgs = cmdArgs.replaceAll("\"","\\\\\"")
111
+
112
+ execute("git clone https://bitbucket.microchip.com/scm/portal/bundles.git")
113
+ execute("cd bundles && chmod 755 ./portal-client-cli-linux")
114
+ execute("git clone https://bitbucket.microchip.com/scm/citd/tool-portal-client-launcher.git")
115
+ execute("cd tool-portal-client-launcher && node portalLauncher.js -app=../bundles/portal-client-cli-linux -cmd=\"uploadGitHub ${cmdArgs}\"")
116
+ sendSuccessfulPortalDeploymentEmail()
117
+ } else {
118
+ echo "Tag name is not equal to metadata content version."
119
+ execute("exit 1")
120
+ }
121
+
122
+ }
123
+ }
124
+ }
80
125
}
126
+
81
127
82
128
post {
83
129
failure {
@@ -113,6 +159,12 @@ def sendPipelineFailureEmail () {
113
159
114
160
def sendSuccessfulGithubDeploymentEmail () {
115
161
mail to: "${params.NOTIFICATION_EMAIL}",
116
- subject: "Successful Deployment: ${currentBuild.fullDisplayName}",
162
+ subject: "Successful Github Deployment: ${currentBuild.fullDisplayName}",
117
163
body: "The changes have been successfully deployed to GitHub. ${env.GITHUB_URL}"
164
+ }
165
+
166
+ def sendSuccessfulPortalDeploymentEmail () {
167
+ mail to: "${params.NOTIFICATION_EMAIL}",
168
+ subject: "Successful Portal Deployment: ${currentBuild.fullDisplayName}",
169
+ body: "The changes have been successfully deployed to Discover Portal."
118
170
}
0 commit comments