1+ // Jenkinsfilek8s v1.2.0
2+
13pipeline {
24 agent {
35 kubernetes {
@@ -9,11 +11,12 @@ pipeline {
911
1012 parameters {
1113 string( name: 'NOTIFICATION_EMAIL',
12- defaultValue: 'PICAVR_Examples_GateKeepers@microchip.com',
13- description: "Email to send build failure, fixed and successful deployment notifications.")
14+ defaultValue: 'PICAVR_Examples_GateKeepers@microchip.com',
15+ description: "Email to send build failure and fixed notifications.")
1416 }
1517
16- environment {
18+ environment {
19+ GITHUB_OWNER = 'microchip-pic-avr-examples'
1720 GITHUB_URL ='https://github.com/microchip-pic-avr-examples/pic18f57q84-2-axis-cnc.git'
1821 BITBUCKET_URL = 'https://bitbucket.microchip.com/scm/ebe/pic18f57q84-2-axis-cnc.git'
1922 DEPLOY_TOOL_URL = 'https://bitbucket.microchip.com/scm/citd/tool-github-deploy.git'
@@ -23,7 +26,7 @@ pipeline {
2326
2427 options {
2528 timestamps()
26- timeout(time: 20 , unit: 'MINUTES')
29+ timeout(time: 30 , unit: 'MINUTES')
2730 }
2831
2932 stages {
@@ -32,6 +35,31 @@ pipeline {
3235 checkout scm
3336 }
3437 }
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+ }
3563
3664 stage('Build') {
3765 steps {
@@ -41,8 +69,8 @@ pipeline {
4169 }
4270 }
4371 }
44-
45- stage('Deploy') {
72+
73+ stage('GitHub- Deploy') {
4674 when {
4775 not {
4876 changeRequest()
@@ -62,8 +90,40 @@ pipeline {
6290 sendSuccessfulGithubDeploymentEmail()
6391 }
6492 }
65- }
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+ }
66125 }
126+
67127
68128 post {
69129 failure {
@@ -99,6 +159,12 @@ def sendPipelineFailureEmail () {
99159
100160def sendSuccessfulGithubDeploymentEmail () {
101161 mail to: "${params.NOTIFICATION_EMAIL}",
102- subject: "Successful Deployment: ${currentBuild.fullDisplayName}",
162+ subject: "Successful Github Deployment: ${currentBuild.fullDisplayName}",
103163 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."
104170}
0 commit comments