Skip to content

Commit 9425f23

Browse files
committed
MPAE-6099 added CI support and readme
1 parent 1b42871 commit 9425f23

File tree

5 files changed

+241
-0
lines changed

5 files changed

+241
-0
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Untracked files in MPLABX projects
2+
/**/build/*
3+
/**/nbproject/*
4+
!/**/nbproject/*.xml
5+
/**/[Ff]ree/production/*
6+
/**/[Pp]ro/production/*
7+
8+
# Uncomment these to include hex/elf files
9+
#!/**/[Ff]ree/production/*.hex
10+
#!/**/[Ff]ree/production/*.elf
11+
#!/**/[Pp]ro/production/*.hex
12+
#!/**/[Pp]ro/production/*.elf

Jenkinsfilek8s

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
// Jenkinsfilek8s v1.2.0
2+
3+
pipeline {
4+
agent {
5+
kubernetes {
6+
label 'avr128db48-getting-started-with-opamp-mplab-mcc'
7+
defaultContainer 'xc8-mplabx'
8+
yamlFile 'cloudprovider.yml'
9+
}
10+
}
11+
12+
parameters {
13+
string( name: 'NOTIFICATION_EMAIL',
14+
defaultValue: 'PICAVR_Examples_GateKeepers@microchip.com',
15+
description: "Email to send build failure and fixed notifications.")
16+
}
17+
18+
environment {
19+
GITHUB_OWNER = 'microchip-pic-avr-examples'
20+
GITHUB_URL ='https://github.com/microchip-pic-avr-examples/avr128db48-getting-started-with-opamp-mplab-mcc.git'
21+
BITBUCKET_URL = 'https://bitbucket.microchip.com/scm/ebe/avr128db48-getting-started-with-opamp-mplab-mcc.git'
22+
DEPLOY_TOOL_URL = 'https://bitbucket.microchip.com/scm/citd/tool-github-deploy.git'
23+
DEPLOY_SCRIPT_DIR = 'tool-github-deploy'
24+
DEPLOY_SCRIPT_FILE = 'deploy-source-as-is.sh'
25+
}
26+
27+
options {
28+
timestamps()
29+
timeout(time: 30, unit: 'MINUTES')
30+
}
31+
32+
stages {
33+
stage('Checkout') {
34+
steps {
35+
checkout scm
36+
}
37+
}
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+
50+
stage('Pre-build') {
51+
steps {
52+
script {
53+
MPLABX_PATH= sh (script: 'update-alternatives --list MPLABX_PATH',returnStdout: true).trim()
54+
COMPILER_PATH= sh (script: 'update-alternatives --list XC8_PATH',returnStdout: true).trim()
55+
def pDir = "${MPLABX_PATH}/packs"
56+
def ver = COMPILER_PATH.split('/')[4].substring(1)
57+
58+
execute("git clone https://bitbucket.microchip.com/scm/citd/tool-mplabx-c-project-generator.git")
59+
execute("cd tool-mplabx-c-project-generator && node configGenerator.js sp=../ v8=${ver} packs=${pDir}")
60+
}
61+
}
62+
}
63+
64+
stage('Build') {
65+
steps {
66+
script {
67+
execute("git clone https://bitbucket.microchip.com/scm/citd/tool-mplabx-c-build.git")
68+
execute("cd tool-mplabx-c-build && node buildLauncher.js sp=../ rp=./output genMK=true")
69+
}
70+
}
71+
}
72+
73+
stage('GitHub-Deploy') {
74+
when {
75+
not {
76+
changeRequest()
77+
}
78+
anyOf {
79+
tag ''
80+
}
81+
}
82+
steps {
83+
script {
84+
execute("git clone ${env.DEPLOY_TOOL_URL}")
85+
86+
withCredentials([usernamePassword(credentialsId: '8bit-examples.github.com', usernameVariable: 'USER_NAME', passwordVariable:'USER_PASS' )]) {
87+
execute("cd ${env.DEPLOY_SCRIPT_DIR} && bash ${env.DEPLOY_SCRIPT_FILE} ${env.BITBUCKET_URL} ${env.GITHUB_URL} ${USER_NAME} ${USER_PASS} '--tag ${env.TAG_NAME}'")
88+
}
89+
90+
sendSuccessfulGithubDeploymentEmail()
91+
}
92+
}
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+
}
125+
}
126+
127+
128+
post {
129+
failure {
130+
script {
131+
sendPipelineFailureEmail()
132+
}
133+
}
134+
always {
135+
archiveArtifacts artifacts: "tool-mplabx-c-build/output/**", allowEmptyArchive: true, fingerprint: true
136+
}
137+
}
138+
}
139+
140+
def execute(String cmd) {
141+
if(isUnix()) {
142+
sh cmd
143+
} else {
144+
bat cmd
145+
}
146+
}
147+
148+
def sendPipelineFailureEmail () {
149+
if (!"${env.CHANGE_AUTHOR_EMAIL}".equalsIgnoreCase("null")) {
150+
mail to: "${env.CHANGE_AUTHOR_EMAIL}, ${params.NOTIFICATION_EMAIL}",
151+
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
152+
body: "Pipeline failure. ${env.BUILD_URL}"
153+
} else {
154+
mail to: "${params.NOTIFICATION_EMAIL}",
155+
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
156+
body: "Pipeline failure. ${env.BUILD_URL}"
157+
}
158+
}
159+
160+
def sendSuccessfulGithubDeploymentEmail () {
161+
mail to: "${params.NOTIFICATION_EMAIL}",
162+
subject: "Successful Github Deployment: ${currentBuild.fullDisplayName}",
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."
170+
}

README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!-- Please do not change this logo with link -->
2+
[![MCHP](images/microchip.png)](https://www.microchip.com)
3+
4+
# Update the title for avr128db48-getting-started-with-opamp-mplab-mcc here
5+
6+
<!-- This is where the introduction to the example goes, including mentioning the peripherals used -->
7+
8+
## Related Documentation
9+
10+
<!-- Any information about an application note or tech brief can be linked here. Use unbreakable links!
11+
In addition a link to the device family landing page and relevant peripheral pages as well:
12+
- [AN3381 - Brushless DC Fan Speed Control Using Temperature Input and Tachometer Feedback](https://microchip.com/00003381/)
13+
- [PIC18F-Q10 Family Product Page](https://www.microchip.com/design-centers/8-bit/pic-mcus/device-selection/pic18f-q10-product-family) -->
14+
15+
## Software Used
16+
17+
<!-- All software used in this example must be listed here. Use unbreakable links!
18+
- MPLAB® X IDE 5.30 or newer [(microchip.com/mplab/mplab-x-ide)](http://www.microchip.com/mplab/mplab-x-ide)
19+
- MPLAB® XC8 2.10 or a newer compiler [(microchip.com/mplab/compilers)](http://www.microchip.com/mplab/compilers)
20+
- MPLAB® Code Configurator (MCC) 3.95.0 or newer [(microchip.com/mplab/mplab-code-configurator)](https://www.microchip.com/mplab/mplab-code-configurator)
21+
- MPLAB® Code Configurator (MCC) Device Libraries PIC10 / PIC12 / PIC16 / PIC18 MCUs [(microchip.com/mplab/mplab-code-configurator)](https://www.microchip.com/mplab/mplab-code-configurator)
22+
- Microchip PIC18F-Q Series Device Support (1.4.109) or newer [(packs.download.microchip.com/)](https://packs.download.microchip.com/) -->
23+
24+
## Hardware Used
25+
26+
<!-- All hardware used in this example must be listed here. Use unbreakable links!
27+
- PIC18F47Q10 Curiosity Nano [(DM182029)](https://www.microchip.com/Developmenttools/ProductDetails/DM182029)
28+
- Curiosity Nano Base for Click boards™ [(AC164162)](https://www.microchip.com/Developmenttools/ProductDetails/AC164162)
29+
- POT Click board™ [(MIKROE-3402)](https://www.mikroe.com/pot-click) -->
30+
31+
## Setup
32+
33+
<!-- Explain how to connect hardware and set up software. Depending on complexity, step-by-step instructions and/or tables and/or images can be used -->
34+
35+
## Operation
36+
37+
<!-- Explain how to operate the example. Depending on complexity, step-by-step instructions and/or tables and/or images can be used -->
38+
39+
## Summary
40+
41+
<!-- Summarize what the example has shown -->

cloudprovider.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: xc8-mplabx
5+
spec:
6+
containers:
7+
- name: xc8-mplabx
8+
image: artifacts.microchip.com:7999/microchip/citd/bundles/xc8-mplabx:latest
9+
imagePullPolicy: Always
10+
command: ['cat']
11+
tty: true
12+
resources:
13+
requests:
14+
cpu: 1
15+
memory: 4Gi
16+
limits:
17+
cpu: 2
18+
memory: 8Gi

images/microchip.png

5.47 KB
Loading

0 commit comments

Comments
 (0)