1
+ /*
2
+ Jenkins Shared Library:
3
+ ----------------------
4
+ shared-library-mcu16ce - https://bitbucket.microchip.com/scm/citd/shared-library-mcu16ce.git
5
+ shared-library-common - https://bitbucket.microchip.com/scm/citd/shared-library-common.git
6
+ */
7
+ @Library(['shared-library-mcu16ce@master', 'shared-library-common@master']) _
8
+
9
+ pipeline {
10
+ agent {
11
+ kubernetes {
12
+ inheritFrom 'dpsk4-power-live-update'
13
+ defaultContainer 'xc16-mplabx-sonar-fmpp-python'
14
+ yamlFile '.citd/cloudprovider.yml'
15
+ }
16
+ }
17
+
18
+ environment {
19
+ /*
20
+ Common Information
21
+ */
22
+ NOTIFICATION_EMAIL = '1f1319de.microchip.com@amer.teams.ms'
23
+ // GitHub production organization name
24
+ // GITHUB_PRODUCTION_ORGANIZATION = "microchip-pic-avr-examples"
25
+ GITHUB_PRODUCTION_ORGANIZATION = "microchip-pic-avr-examples"
26
+ /*
27
+ GitHub Deploy Stage Information
28
+ */
29
+ //This is the BitBucket source repo URL to be deployed
30
+ BITBUCKET_SOURCE_URL = 'https://bitbucket.microchip.com/scm/mcu16ce/dpsk4-power-live-update.git'
31
+ //Files or folders to be excluded from deployment, if multiple files or folders use comma separator
32
+ DEPLOY_EXCLUDE_FOLDER_FILE_LIST = 'mchp_private,.mchp_private,mchp-private,.mchp-private,sandbox,.sandbox,test,.test'
33
+ //Branch(s) to be deployed, if multiple branches use comma separator. DEPLOY_BRANCH_LIST is the target branch of the PR.
34
+ DEPLOY_BRANCH_LIST = "master,main"
35
+ /*When using the main.json schema version 1.3.0 or higher, the PORTAL will first reject registration attempt when an unapproved keyword is found, but can be forced to accept.
36
+ This argument is used to provide the list of unapproved keywords (also listed in main.json) which the deployment script will force the PORTAL to accept.*/
37
+ UNAPPROVED_KEYWORDS_OVERRIDE_LIST="NONE"
38
+
39
+ /*
40
+ GitHub Page Stage Information
41
+ List of GitHub Page Options:
42
+ ----------------------------
43
+ 1. GITHUB_PAGES_NONE ( Branch: None, index file path: None )
44
+ 2. GITHUB_PAGES_MASTER_ROOT ( Branch: Master, index file path: /root )
45
+ 3. GITHUB_PAGES_MASTER_DOCS ( Branch: Master, index file path: /Docs )
46
+ 4. GITHUB_PAGES_DEVELOP_ROOT ( Branch: Develop, index file path: /root )
47
+ 5. GITHUB_PAGES_DEVELOP_DOCS ( Branch: Develop, index file path: /Docs )
48
+ */
49
+ GITHUB_PAGES = 'GITHUB_PAGES_NONE'
50
+
51
+ /*
52
+ Project Build Stage Information
53
+ */
54
+ MPLABX_PROJECT_SOURCE = "../"
55
+ }
56
+
57
+ triggers {
58
+ cron(env.BRANCH_NAME == 'develop' ? 'H H 1 * *': '')
59
+ }
60
+
61
+ options {
62
+ timestamps()
63
+ timeout(time: 30, unit: 'MINUTES')
64
+ }
65
+
66
+ stages {
67
+ stage('Checkout') {
68
+ steps {
69
+ checkout scm
70
+ }
71
+ }
72
+
73
+ stage('project config update') {
74
+ steps {
75
+ script {
76
+ mplabxProjectConfigUpdate(
77
+ sourceFilePath: "${env.MPLABX_PROJECT_SOURCE}",
78
+ dfpUpdate: false,
79
+ dfpInternal: false
80
+ )
81
+ }
82
+ }
83
+ }
84
+
85
+ stage('Build') {
86
+ steps {
87
+ script {
88
+ mplabxProjectBuild(
89
+ sourceFilePath: "${env.MPLABX_PROJECT_SOURCE}"
90
+ )
91
+ }
92
+ }
93
+ }
94
+
95
+
96
+ //MisraCheck code analysis
97
+ stage('MISRA Check') {
98
+ steps {
99
+ script {
100
+ misraCheck(
101
+ sourceProjectPath: "${env.MPLABX_PROJECT_SOURCE}"
102
+ )
103
+ }
104
+ }
105
+ }
106
+
107
+ // Validate main.json file
108
+ stage('Validate main.json') {
109
+ steps {
110
+ script {
111
+ validateMetaData(
112
+ unapprovedKeywordsOverrideList: "${UNAPPROVED_KEYWORDS_OVERRIDE_LIST}"
113
+ )
114
+ }
115
+ }
116
+ }
117
+
118
+ stage('Doxygen files generation') {
119
+ when {
120
+ anyOf {
121
+ allOf {
122
+ not { changeRequest() }
123
+ }
124
+ }
125
+ }
126
+ steps {
127
+ container('buildtools') {
128
+ script {
129
+ doxygen()
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+ // GitHub repo creation
136
+ stage('GitHub Repo Creation') {
137
+ when {
138
+ anyOf {
139
+ allOf {
140
+ not { changeRequest() }
141
+ anyOf {branch 'master'; branch 'main'; branch 'test_deploy';}
142
+ }
143
+ }
144
+ }
145
+
146
+ steps {
147
+ script {
148
+ githubRepoCreate(
149
+ githubOrgName: "${env.GITHUB_PRODUCTION_ORGANIZATION}",
150
+ deployBranchList: "${DEPLOY_BRANCH_LIST}"
151
+ )
152
+ }
153
+ }
154
+ }
155
+
156
+ // Deploying the code to GitHub
157
+ stage('GitHub Deploy Source') {
158
+ when {
159
+ anyOf {
160
+ allOf {
161
+ not { changeRequest() }
162
+ anyOf {branch 'master'; branch 'main'; branch 'test_deploy';}
163
+ }
164
+ }
165
+ }
166
+
167
+ steps {
168
+ script {
169
+ githubDeploySource(
170
+ bitbucketUrl: "${env.BITBUCKET_SOURCE_URL}",
171
+ deployBranchList: "${env.DEPLOY_BRANCH_LIST}",
172
+ deployExcludeFileList: "${env.DEPLOY_EXCLUDE_FOLDER_FILE_LIST}",
173
+ githubOrgName: "${env.GITHUB_PRODUCTION_ORGANIZATION}"
174
+ )
175
+ }
176
+ }
177
+ }
178
+
179
+ // Creating GitHub release
180
+ stage('GitHub release') {
181
+ when {
182
+ anyOf {
183
+ allOf {
184
+ not { changeRequest() }
185
+ anyOf {branch 'master'; branch 'main'; branch 'test_deploy';}
186
+ }
187
+ }
188
+ }
189
+
190
+ steps {
191
+ script {
192
+ githubReleaseCreate(
193
+ githubOrgName: "${env.GITHUB_PRODUCTION_ORGANIZATION}",
194
+ deployBranchList: "${DEPLOY_BRANCH_LIST}"
195
+ )
196
+ }
197
+ }
198
+ }
199
+
200
+ // Creating GitHub Page
201
+ stage('GitHub Page Create') {
202
+ when {
203
+ anyOf {
204
+ allOf {
205
+ not { changeRequest() }
206
+ anyOf {branch 'master'; branch 'main';}
207
+ }
208
+ }
209
+ }
210
+
211
+ steps {
212
+ script {
213
+ githubPageCreate(
214
+ githubPage: "${env.GITHUB_PAGES}",
215
+ githubOrgName: "${env.GITHUB_PRODUCTION_ORGANIZATION}"
216
+ )
217
+ }
218
+ }
219
+ }
220
+
221
+ //Deploying the Github content to portal
222
+ stage('Portal-Deploy') {
223
+ when {
224
+ allOf {
225
+ not { changeRequest() }
226
+ anyOf {branch 'master'; branch 'main';}
227
+ }
228
+ }
229
+ steps {
230
+ script {
231
+ portalDeploy(
232
+ githubOrgName: "${env.GITHUB_PRODUCTION_ORGANIZATION}",
233
+ unapprovedKeywordsOverrideList: "${UNAPPROVED_KEYWORDS_OVERRIDE_LIST}"
234
+ )
235
+ }
236
+ }
237
+ }
238
+ }
239
+
240
+ post {
241
+ success{
242
+ script {
243
+ sendMail(
244
+ mailId: "${env.NOTIFICATION_EMAIL}",
245
+ subject: "Successful Pipeline: ${currentBuild.fullDisplayName}",
246
+ body: "Something is right with ${env.BUILD_URL}"
247
+ )
248
+ }
249
+ }
250
+ failure {
251
+ script {
252
+ sendMail(
253
+ mailId: "${env.NOTIFICATION_EMAIL}",
254
+ subject: "Failure Pipeline: ${currentBuild.fullDisplayName}",
255
+ body: "Something is right with ${env.BUILD_URL}"
256
+ )
257
+ }
258
+ }
259
+ }
260
+ }
0 commit comments