Skip to content

Commit c822469

Browse files
committed
Merge pull request #33 in MCU16CE/pic24f-hello-world-uart from ~I15232/pic24f-hello-world-uart:feature/MergeDevelopToMaster to master
* commit 'e5d4799e05693645e97a902d098c68395c2f1fe7': (41 commits) Addressed review comments Added MCC configuration file Updated Jenkins script Addressed review comments script updated Updated jenkins script Updated jenkins script Added portal deploy stage Addressed review comments Addressed review comments removed "deploy_sandbox" from changelog.md path Removed cppcheck stage Added cppcheck stage Addressed review comments Resized image using imageResizer LICENSE.txt and README.md files added Files deleted added the folder to be excluded from deployment as an argument Changed the extension of license file from .md to .txt Added Bitbucket tag creation stage ...
2 parents 113901e + e5d4799 commit c822469

30 files changed

+17838
-47
lines changed

.citd/Jenkinsfilek8s

Lines changed: 173 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,21 @@ pipeline {
1010

1111
environment {
1212
NOTIFICATION_EMAIL = '[email protected]'
13-
//Update this URL based on where(which organization) it needs to be deployed
14-
GITHUB_URL ='https://github.com/mchpTestArea'
15-
//This is the BitBucket repo URL which we want to deploy
16-
BITBUCKET_URL = 'https://bitbucket.microchip.com/scm/mcu16ce/pic24f-hello-world-uart.git'
17-
GITHUB_CREDENTIAL_ID = 'GITHUB_PIC_AVR_TEST_TOKEN'
13+
//This is the BitBucket source repo URL to be deployed
14+
BITBUCKET_SOURCE_URL = 'https://bitbucket.microchip.com/scm/mcu16ce/pic24f-hello-world-uart.git'
15+
BITBUCKET_CREDENTIAL_ID = 'BITBUCKET_INTERNAL_TOKEN'
16+
GITHUB_PRODUCTION_DEPLOY_URL ='https://github.com/microchip-pic-avr-examples'
17+
GITHUB_TEST_DEPLOY_URL ='https://github.com/mchpTestArea'
18+
//Selects the deployment URL(production or test) based on the merge target branch, selects "microchip-pic-avr-examples" if target branch is "master" , if target branch is "test_deploy" selects "mchpTestArea" else null
19+
GITHUB_URL = getGitHubUrl("${GITHUB_PRODUCTION_DEPLOY_URL}","${GITHUB_TEST_DEPLOY_URL}")
20+
GITHUB_PRODUCTION_DEPLOY_CREDENTIAL_ID ='GITHUB_MICROCHIP_PIC_AVR_EXAMPLES_TOKEN'
21+
GITHUB_TEST_DEPLOY_CREDENTIAL_ID ='GITHUB_PIC_AVR_TEST_TOKEN'
22+
//Gets the Github credential id based on the deployment organization
23+
GITHUB_CREDENTIAL_ID = getGitHubCredentialId("${GITHUB_URL}","${GITHUB_PRODUCTION_DEPLOY_URL}","${GITHUB_TEST_DEPLOY_URL}","${GITHUB_PRODUCTION_DEPLOY_CREDENTIAL_ID}","${GITHUB_TEST_DEPLOY_CREDENTIAL_ID}")
24+
//Files or folders to be excluded from deployment, if multiple files or folders use comma separator
25+
DEPLOY_EXCLUDE_FOLDER_FILE_LIST = 'mchp_private'
26+
//Branch(s) to be deployed, if multiple branches use comma separator. ${env.BRANCH_NAME} is the target branch of the PR.
27+
DEPLOY_BRANCH_LIST = "${env.BRANCH_NAME}"
1828
CHANGE_LOG_PATH = 'changelog.md'
1929
SOURCE_PROJECT_META_DATA = '.main-meta/main.json'
2030
DEPLOY_TOOL_URL = 'https://bitbucket.microchip.com/scm/citd/tool-github-deploy.git'
@@ -32,7 +42,7 @@ pipeline {
3242
checkout scm
3343
}
3444
}
35-
45+
3646
stage('Build') {
3747
steps {
3848
script {
@@ -41,9 +51,17 @@ pipeline {
4151
}
4252
}
4353
}
44-
54+
4555
// Cloning the tool used for GitHub deployment
4656
stage('GitHub tool clone'){
57+
when {
58+
anyOf {
59+
allOf {
60+
not { changeRequest() }
61+
anyOf {branch 'master'; branch 'test_deploy';}
62+
}
63+
}
64+
}
4765
steps{
4866
script{
4967
execute("git clone https://bitbucket.microchip.com/scm/citd/tool-github-deploy.git")
@@ -52,16 +70,141 @@ pipeline {
5270
}
5371
}
5472

73+
// Creating tag in Bitbucket repo
74+
stage('Bitbucket Tag Creation'){
75+
when {
76+
anyOf {
77+
allOf {
78+
not { changeRequest() }
79+
anyOf {branch 'master'; branch 'test_deploy';}
80+
}
81+
}
82+
}
83+
steps{
84+
script{
85+
def jsonObj = readJsonObject();
86+
87+
withCredentials([usernamePassword(credentialsId: "${env.BITBUCKET_CREDENTIAL_ID}", passwordVariable: 'PASS', usernameVariable: 'USER_NAME')]) {
88+
execute("python tool-github-deploy/tool-github-deploy/tool-github-deploy.py -bto=true -rpn=\"${jsonObj.content.projectName}\" -bid=$USER_NAME -bpat=$PASS -bpn=MCU16CE -btv=\"${jsonObj.content.version}\" -bch=${env.GIT_COMMIT} -btd=\"v${jsonObj.content.version}\"")
89+
}
90+
}
91+
}
92+
}
93+
94+
// GitHub repo creation
95+
stage('GitHub Repo Creation'){
96+
when {
97+
anyOf {
98+
allOf {
99+
not { changeRequest() }
100+
anyOf {branch 'master'; branch 'test_deploy';}
101+
}
102+
}
103+
}
104+
steps{
105+
script{
106+
def jsonObj = readJsonObject();
107+
108+
String [] topics = jsonObj.content.keywords
109+
def asString = topics.join(", ")
110+
asString = asString.replace("\n", "").replace(" ", "").replace("\t", "").replace("\r", "")
111+
Boolean visibility = true
112+
if(env.GITHUB_URL == env.GITHUB_PRODUCTION_DEPLOY_URL)
113+
{
114+
visibility = false
115+
}
116+
117+
withCredentials([usernamePassword(credentialsId: "${env.GITHUB_CREDENTIAL_ID}", passwordVariable: 'PASS', usernameVariable: 'USER_NAME')]) {
118+
execute("python tool-github-deploy/tool-github-deploy/tool-github-deploy.py -rpo=true -gpat=$PASS -rporg=${env.GITHUB_URL} -rpn=${jsonObj.content.projectName} -rpd=\"${jsonObj.content.shortDescription}\" -rpt=${asString} -rpp=${visibility}")
119+
}
120+
}
121+
}
122+
}
123+
124+
// Deploying the code to GitHub
125+
stage('GitHub Deploy Source'){
126+
when {
127+
anyOf {
128+
allOf {
129+
not { changeRequest() }
130+
anyOf {branch 'master'; branch 'test_deploy';}
131+
}
132+
}
133+
}
134+
steps{
135+
script{
136+
def jsonObj = readJsonObject();
137+
def gitHubUrl = "${env.GITHUB_URL}" + "/" + jsonObj.content.projectName
138+
gitHubUrl = gitHubUrl.replace(" ", "").replace("\n", "")
139+
140+
withCredentials([usernamePassword(credentialsId: "${env.GITHUB_CREDENTIAL_ID}", passwordVariable: 'PASS', usernameVariable: 'USER_NAME')]) {
141+
execute("python tool-github-deploy/tool-github-deploy/tool-github-deploy.py -deploy=true -gpat=$PASS -dgid=$USER_NAME -dburl=${env.BITBUCKET_SOURCE_URL} -dgurl=${gitHubUrl} -dbranch=${env.DEPLOY_BRANCH_LIST} -def=${env.DEPLOY_EXCLUDE_FOLDER_FILE_LIST}")
142+
}
143+
}
144+
}
145+
}
146+
147+
// Creating GitHub release
148+
stage('GitHub release'){
149+
when {
150+
anyOf {
151+
allOf {
152+
not { changeRequest() }
153+
anyOf {branch 'master'; branch 'test_deploy';}
154+
}
155+
}
156+
}
157+
steps{
158+
script{
159+
def jsonObj = readJsonObject();
160+
161+
withCredentials([usernamePassword(credentialsId: "${env.GITHUB_CREDENTIAL_ID}", passwordVariable: 'PASS', usernameVariable: 'USER_NAME')]) {
162+
execute("python tool-github-deploy/tool-github-deploy/tool-github-deploy.py -rlo=true -gpat=$PASS -rpn=\"${jsonObj.content.projectName}\" -rltv=\"v${jsonObj.content.version}\" -rltt=\"${jsonObj.content.version}\" -rlnp=${env.CHANGE_LOG_PATH}")
163+
}
164+
}
165+
}
166+
}
167+
168+
//Deploying the Github content to portal
169+
stage('Portal-Deploy') {
170+
when {
171+
allOf {
172+
not { changeRequest() }
173+
anyOf {branch 'master';}
174+
}
175+
}
176+
steps {
177+
script {
178+
def jsonObj = readJsonObject();
179+
def version = jsonObj.content.version
180+
def project = jsonObj.content.projectName
181+
182+
String[] splitPreTag = "${env.GITHUB_URL}".split("/")
183+
def gitHubOrg = (splitPreTag[splitPreTag.size() - 1])
184+
185+
def cmdArgs = "'{\"repoOwnerName\":\"$gitHubOrg\",\"repoName\":\"$project\",\"tagName\":\"$version\"}'"
186+
cmdArgs = cmdArgs.replaceAll("\"","\\\\\"")
187+
188+
execute("git clone https://bitbucket.microchip.com/scm/portal/bundles.git")
189+
execute("cd bundles && chmod 755 ./portal-client-cli-linux")
190+
execute("git clone https://bitbucket.microchip.com/scm/citd/tool-portal-client-launcher.git")
191+
execute("cd tool-portal-client-launcher && node portalLauncher.js -app=../bundles/portal-client-cli-linux -cmd=\"uploadGitHub ${cmdArgs}\"")
192+
}
193+
}
194+
}
195+
55196
}
56197

57198
post {
58199
success{
59200
script {
60201
if (!"${env.CHANGE_AUTHOR_EMAIL}".equalsIgnoreCase("null")) {
202+
archiveArtifacts artifacts: "tool-mplabx-c-build/output/**", fingerprint: true
61203
mail to: "${env.CHANGE_AUTHOR_EMAIL}, ${env.NOTIFICATION_EMAIL}",
62204
subject: "Successful Pipeline: ${currentBuild.fullDisplayName}",
63205
body: "Something is right with ${env.BUILD_URL}"
64206
} else {
207+
archiveArtifacts artifacts: "tool-mplabx-c-build/output/**", fingerprint: true
65208
mail to: "${env.NOTIFICATION_EMAIL}",
66209
subject: "Successful Pipeline: ${currentBuild.fullDisplayName}",
67210
body: "Something is right with ${env.BUILD_URL}"
@@ -71,10 +214,12 @@ pipeline {
71214
failure {
72215
script {
73216
if (!"${env.CHANGE_AUTHOR_EMAIL}".equalsIgnoreCase("null")) {
217+
archiveArtifacts artifacts: "tool-mplabx-c-build/output/**", fingerprint: true
74218
mail to: "${env.CHANGE_AUTHOR_EMAIL}, ${env.NOTIFICATION_EMAIL}",
75219
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
76220
body: "Pipeline failure. ${env.BUILD_URL}"
77221
} else {
222+
archiveArtifacts artifacts: "tool-mplabx-c-build/output/**", fingerprint: true
78223
mail to: "${env.NOTIFICATION_EMAIL}",
79224
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
80225
body: "Pipeline failure. ${env.BUILD_URL}"
@@ -96,3 +241,24 @@ String readJsonObject() {
96241
def jsonObj = readJSON interpolate: true, file: "${env.SOURCE_PROJECT_META_DATA}"
97242
return jsonObj
98243
}
244+
245+
def getGitHubUrl(String productionUrl, String testDeployUrl) {
246+
String branchName = "${env.BRANCH_NAME}";
247+
if(branchName == 'master') {
248+
return productionUrl;
249+
} else if(branchName == 'test_deploy') {
250+
return testDeployUrl;
251+
} else {
252+
return null
253+
}
254+
}
255+
256+
def getGitHubCredentialId(String deployUrl, String productionDeployUrl, String testDeployUrl, String githubProductionDeployCredential, String githubTestDeployCredential) {
257+
if(deployUrl == productionDeployUrl) {
258+
return githubProductionDeployCredential;
259+
} else if(deployUrl == testDeployUrl) {
260+
return githubTestDeployCredential;
261+
} else {
262+
return null
263+
}
264+
}

.citd/cloudprovider.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ spec:
1616
limits:
1717
cpu: 2
1818
memory: 2Gi
19+

.main-meta/main.json

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"category": "com.microchip.ide.project",
44
"content": {
55
"metaDataVersion": "1.0.0",
6-
"name": "com.microchip.mplabx.project.project",
6+
"name": "com.microchip.mplabx.project.pic24f-hello-world-uart",
77
"version": "1.0.0",
8-
"displayName": "PIC24F Hello World",
8+
"displayName": "PIC24F Hello World UART",
99
"projectName": "pic24f-hello-world-uart",
10-
"shortDescription": "PIC24F Hello World Example",
10+
"shortDescription": "PIC24F Hello World UART Example",
1111
"ide": {
1212
"name": "MPLABX",
13-
"semverRange": ">=5.35.0"
13+
"semverRange": ">=5.40.0"
1414
},
1515
"compiler": {
1616
"name": "XC16",
@@ -30,14 +30,6 @@
3030
"versionRange": "*"
3131
}
3232
},
33-
"subcategories":[
34-
"Hello World",
35-
[
36-
"Peripherals",
37-
"GPIO",
38-
"UART"
39-
]
40-
],
4133
"peripherals": [
4234
"GPIO",
4335
"UART"

LICENSE.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
© [2020] Microchip Technology Inc. and its subsidiaries
2+
3+
Subject to your compliance with these terms, you may use this Microchip software and any derivatives exclusively with Microchip products. You are responsible
4+
for complying with third party license terms applicable to your use of third party software (including open source software) that may accompany this Microchip
5+
software. SOFTWARE IS “AS IS.” NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT,
6+
MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS,
7+
DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE
8+
FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP’S TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT EXCEED AMOUNT OF FEES, IF ANY, YOU
9+
PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
![image](images/microchip.jpg)
2+
3+
## PIC24F Hello World UART
4+
5+
## Summary
6+
7+
This is a simple Hello world application which prints the string "Hello World !!!" continuously on the serial terminal.
8+
9+
## Related Documentation
10+
11+
- PIC24FJ1024GB610 microcontroller (https://www.microchip.com/PIC24FJ1024GB610)
12+
13+
14+
## Software Used
15+
16+
- MPLAB® X IDE v5.35 or newer (https://www.microchip.com/mplabx)
17+
- MPLAB® XC16 v1.50 or newer (https://www.microchip.com/xc)
18+
- Any of the serial terminal application. Example: Tera Term (https://ttssh2.osdn.jp/index.html.en)
19+
20+
21+
## Hardware Used
22+
23+
- Explorer 16/32 Development Board (https://www.microchip.com/DM240001-2)
24+
- PIC24FJ1024GB610 PIM (https://www.microchip.com/MA240023)
25+
- Micro USB Cable
26+
27+
28+
## Setup
29+
- Make sure J37 and J38 jumpers are installed.
30+
- Connect the Micro USB Cable to the serial connector(J40) in the Explorer 16/32 Development Board.
31+
32+
33+
## Operation
34+
35+
Build the Project and program the device. Once the application code is flashed on to the device, open the serial terminal application and configure the baudrate to 9600 , No parity , 8 Data bits and 1 Stop bit and no flow control.
36+
Users will see the string "Hello World !!!" being continuously printed on the serial terminal.
37+
38+
![image](images/hardware_connections.jpg)
39+
40+
![image](images/serial_terminal.jpg)
41+
42+

changelog.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
# Product name release version Ex: pic24f-hello-worl-uart release v1.0.0
1+
# pic24f-hello-world-uart release v1.0.0
22
### Release Highlights
33

4-
4+
This is a simple hello world example.
55

66
### Features Added\Updated
77

8+
Prints the string "Hello World" on the Serial Terminal.
9+
For more details about the functionality and features supported please refer readme.md file.
10+

images/explorer16_32_dev_board.jpg

149 KB
Loading

images/hardware_connections.jpg

101 KB
Loading

images/microchip.jpg

6.71 KB
Loading

images/serial_terminal.jpg

34.1 KB
Loading

0 commit comments

Comments
 (0)