1+ // Jenkinsfilek8s v1.2.0
2+
13pipeline {
24 agent {
35 kubernetes {
@@ -13,7 +15,8 @@ pipeline {
1315 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/atmega4809-adc-basics-mplab.git'
1821 BITBUCKET_URL = 'https://bitbucket.microchip.com/scm/ebe/atmega4809-adc-basics-mplab.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 {
@@ -33,6 +36,17 @@ pipeline {
3336 }
3437 }
3538
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+
3650 stage('Pre-build') {
3751 steps {
3852 script {
@@ -56,7 +70,7 @@ pipeline {
5670 }
5771 }
5872
59- stage('Deploy') {
73+ stage('GitHub- Deploy') {
6074 when {
6175 not {
6276 changeRequest()
@@ -76,8 +90,40 @@ pipeline {
7690 sendSuccessfulGithubDeploymentEmail()
7791 }
7892 }
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+ }
80125 }
126+
81127
82128 post {
83129 failure {
@@ -113,6 +159,12 @@ def sendPipelineFailureEmail () {
113159
114160def sendSuccessfulGithubDeploymentEmail () {
115161 mail to: "${params.NOTIFICATION_EMAIL}",
116- subject: "Successful Deployment: ${currentBuild.fullDisplayName}",
162+ subject: "Successful Github Deployment: ${currentBuild.fullDisplayName}",
117163 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."
118170}
0 commit comments