Skip to content

Commit d38f23e

Browse files
Akashkumar Natavarlal JivaniAkashkumar Natavarlal Jivani
authored andcommitted
MCU8QA-467 added new CICD files
1 parent 7dd9563 commit d38f23e

File tree

1 file changed

+28
-124
lines changed

1 file changed

+28
-124
lines changed

.citd/Jenkinsfile

Lines changed: 28 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,58 @@
1-
// Jenkinsfile v1.2.0
2-
1+
// Jenkinsfile v2.0.0
32
pipeline {
43
agent {
5-
label 'windows'
4+
label 'windows'
65
}
7-
86
parameters {
97
string( name: 'NOTIFICATION_EMAIL',
10-
defaultValue: 'PICAVR_Examples_GateKeepers@microchip.com',
11-
description: "Email to send build failure, fixed and successful deployment notifications.")
8+
defaultValue: 'PICAVR_Examples_GateKeepers@microchip.com',
9+
description: "Email to send build failure and fixed notifications.")
1210
}
1311

1412
environment {
15-
GITHUB_OWNER = 'microchip-pic-avr-examples'
16-
GITHUB_URL ='https://github.com/microchip-pic-avr-examples/atmega4809-getting-started-with-usart-studio.git'
13+
GITHUB_OWNER = 'microchip-pic-avr-examples'
14+
GITHUB_URL ='https://github.com/microchip-pic-avr-examples/atmega4809-getting-started-with-usart-studio'
1715
BITBUCKET_URL = 'https://bitbucket.microchip.com/scm/ebe/atmega4809-getting-started-with-usart-studio.git'
18-
DEPLOY_TOOL_URL = 'https://bitbucket.microchip.com/scm/citd/tool-github-deploy.git'
19-
DEPLOY_SCRIPT_DIR = 'tool-github-deploy'
20-
DEPLOY_SCRIPT_FILE = 'deploy-source-as-is.sh'
16+
SEMVER_REGEX = '^(0|[1-9]\\d*)+\\.(0|[1-9]\\d*)+\\.(0|[1-9]\\d*)+$'
17+
ARTIFACTORY_SERVER = 'https://artifacts.microchip.com:7999/artifactory'
18+
}
19+
options {
20+
timestamps()
21+
timeout(time: 30, unit: 'MINUTES')
2122
}
2223

23-
options {
24-
timestamps()
25-
timeout(time: 30, unit: 'MINUTES')
26-
}
27-
28-
stages {
29-
stage('Checkout') {
30-
steps {
31-
checkout scm
32-
}
33-
}
34-
35-
stage('metadata') {
36-
steps {
37-
script {
38-
execute("pip install jsonschema")
39-
execute("git clone https://bitbucket.microchip.com/scm/citd/metadata-schema.git")
40-
execute("git clone https://bitbucket.microchip.com/scm/citd/tool-metadata-validator.git")
41-
execute("cd tool-metadata-validator && python metadata-validator.py -data ../.main-meta/main.json -schema ../metadata-schema/main-schema.json")
42-
}
43-
}
44-
}
45-
46-
stage('Build') {
47-
steps {
24+
stages {
25+
stage('setup') {
26+
steps {
4827
script {
49-
execute("git clone https://bitbucket.microchip.com/scm/citd/tool-studio-c-build.git")
50-
execute("cd tool-studio-c-build && python studiobuildtool.py")
51-
52-
}
53-
}
54-
}
55-
56-
stage('GitHub-Deploy') {
57-
when {
58-
not {
59-
changeRequest()
60-
}
61-
anyOf {
62-
tag ''
28+
execute("git clone https://bitbucket.microchip.com/scm/citd/mpae-buildpipeline-groovy-scripts.git")
29+
def buildPipeline = load ('mpae-buildpipeline-groovy-scripts/studio-buildpipeline.groovy')
30+
buildPipeline.runStages()
6331
}
6432
}
65-
steps {
66-
script {
67-
execute("git clone ${env.DEPLOY_TOOL_URL}")
68-
69-
withCredentials([usernamePassword(credentialsId: '8bit-examples.github.com', usernameVariable: 'USER_NAME', passwordVariable:'USER_PASS' )]) {
70-
execute("cd ${env.DEPLOY_SCRIPT_DIR} && sh ${env.DEPLOY_SCRIPT_FILE} ${env.BITBUCKET_URL} ${env.GITHUB_URL} ${USER_NAME} ${USER_PASS} '--tag ${env.TAG_NAME}'")
71-
}
72-
73-
sendSuccessfulGithubDeploymentEmail()
74-
}
75-
}
76-
}
77-
78-
stage('Portal-Deploy') {
79-
when {
80-
not {
81-
changeRequest()
82-
}
83-
tag ''
84-
}
85-
steps {
86-
script {
87-
def metadata = readJSON file:".main-meta/main.json"
88-
def version = metadata.content.version
89-
def project = metadata.content.projectName
90-
91-
if(version == env.TAG_NAME) {
92-
def cmdArgs = "'{\"repoOwnerName\":\"$env.GITHUB_OWNER\",\"repoName\":\"$project\",\"tagName\":\"$version\"}'"
93-
cmdArgs = cmdArgs.replaceAll("\"","\\\\\"")
94-
95-
execute("git clone https://bitbucket.microchip.com/scm/portal/bundles.git")
96-
execute("git clone https://bitbucket.microchip.com/scm/citd/tool-portal-client-launcher.git")
97-
execute("cd tool-portal-client-launcher && node portalLauncher.js -app=../bundles/portal-client-cli-win.exe -cmd=\"uploadGitHub ${cmdArgs}\"")
98-
sendSuccessfulPortalDeploymentEmail()
99-
} else {
100-
echo "Tag name is not equal to metadata content version."
101-
execute("exit 1")
102-
}
103-
104-
}
105-
}
10633
}
10734
}
108-
109-
post {
35+
36+
post {
11037
failure {
11138
script {
11239
sendPipelineFailureEmail()
11340
}
11441
}
115-
always {
116-
archiveArtifacts artifacts: "tool-studio-c-build/output/**", allowEmptyArchive: true, fingerprint: true
117-
script{
118-
cleanWs()
119-
}
120-
}
121-
}
42+
always{
43+
cleanWs()
44+
}
45+
}
12246
}
123-
12447
def execute(String cmd) {
12548
if(isUnix()) {
12649
sh cmd
12750
} else {
12851
bat cmd
12952
}
13053
}
131-
132-
def sendPipelineFailureEmail () {
133-
if (!"${env.CHANGE_AUTHOR_EMAIL}".equalsIgnoreCase("null")) {
134-
mail to: "${env.CHANGE_AUTHOR_EMAIL}, ${params.NOTIFICATION_EMAIL}",
135-
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
136-
body: "Pipeline failure. ${env.BUILD_URL}"
137-
} else {
138-
mail to: "${params.NOTIFICATION_EMAIL}",
139-
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
140-
body: "Pipeline failure. ${env.BUILD_URL}"
141-
}
142-
}
143-
144-
def sendSuccessfulGithubDeploymentEmail () {
145-
mail to: "${params.NOTIFICATION_EMAIL}",
146-
subject: "Successful Github Deployment: ${currentBuild.fullDisplayName}",
147-
body: "The changes have been successfully deployed to GitHub. ${env.GITHUB_URL}"
148-
}
149-
150-
def sendSuccessfulPortalDeploymentEmail () {
151-
mail to: "${params.NOTIFICATION_EMAIL}",
152-
subject: "Successful Portal Deployment: ${currentBuild.fullDisplayName}",
153-
body: "The changes have been successfully deployed to Discover Portal."
54+
def sendPipelineFailureEmail() {
55+
mail to: "${env.EMAILLIST},${params.NOTIFICATION_EMAIL}",
56+
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
57+
body: "Pipeline failure. ${env.BUILD_URL}"
15458
}

0 commit comments

Comments
 (0)