|
| 1 | +pipeline { |
| 2 | + agent { |
| 3 | + kubernetes { |
| 4 | + label 'github_deployment' |
| 5 | + defaultContainer 'xc16-mplabx-sonar-fmpp-python' |
| 6 | + yamlFile '.citd/cloudprovider.yml' |
| 7 | + } |
| 8 | + } |
| 9 | + |
| 10 | + |
| 11 | + environment { |
| 12 | + 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' |
| 18 | + CHANGE_LOG_PATH = 'changelog.md' |
| 19 | + SOURCE_PROJECT_META_DATA = '.main-meta/main.json' |
| 20 | + DEPLOY_TOOL_URL = 'https://bitbucket.microchip.com/scm/citd/tool-github-deploy.git' |
| 21 | + } |
| 22 | + |
| 23 | + options { |
| 24 | + timestamps() |
| 25 | + timeout(time: 20, unit: 'MINUTES') |
| 26 | + } |
| 27 | + |
| 28 | + stages { |
| 29 | + |
| 30 | + stage('Checkout') { |
| 31 | + steps { |
| 32 | + checkout scm |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + stage('Build') { |
| 37 | + steps { |
| 38 | + script { |
| 39 | + execute("git clone https://bitbucket.microchip.com/scm/citd/tool-mplabx-c-build.git") |
| 40 | + execute("cd ./tool-mplabx-c-build && node buildLauncher.js sp=../ rp=./output genMK=true") |
| 41 | + } |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + // Cloning the tool used for GitHub deployment |
| 46 | + stage('GitHub tool clone'){ |
| 47 | + steps{ |
| 48 | + script{ |
| 49 | + execute("git clone https://bitbucket.microchip.com/scm/citd/tool-github-deploy.git") |
| 50 | + execute("chmod +x ./tool-github-deploy/tool-github-deploy/tool-github-deploy.py") |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + } |
| 56 | + |
| 57 | + post { |
| 58 | + success{ |
| 59 | + script { |
| 60 | + if (!"${env.CHANGE_AUTHOR_EMAIL}".equalsIgnoreCase("null")) { |
| 61 | + archiveArtifacts artifacts: "tool-mplabx-c-build/output/**", fingerprint: true |
| 62 | + mail to: "${env.CHANGE_AUTHOR_EMAIL}, ${env.NOTIFICATION_EMAIL}", |
| 63 | + subject: "Successful Pipeline: ${currentBuild.fullDisplayName}", |
| 64 | + body: "Something is right with ${env.BUILD_URL}" |
| 65 | + } else { |
| 66 | + archiveArtifacts artifacts: "tool-mplabx-c-build/output/**", fingerprint: true |
| 67 | + mail to: "${env.NOTIFICATION_EMAIL}", |
| 68 | + subject: "Successful Pipeline: ${currentBuild.fullDisplayName}", |
| 69 | + body: "Something is right with ${env.BUILD_URL}" |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | + failure { |
| 74 | + script { |
| 75 | + if (!"${env.CHANGE_AUTHOR_EMAIL}".equalsIgnoreCase("null")) { |
| 76 | + archiveArtifacts artifacts: "tool-mplabx-c-build/output/**", fingerprint: true |
| 77 | + mail to: "${env.CHANGE_AUTHOR_EMAIL}, ${env.NOTIFICATION_EMAIL}", |
| 78 | + subject: "Failed Pipeline: ${currentBuild.fullDisplayName}", |
| 79 | + body: "Pipeline failure. ${env.BUILD_URL}" |
| 80 | + } else { |
| 81 | + archiveArtifacts artifacts: "tool-mplabx-c-build/output/**", fingerprint: true |
| 82 | + mail to: "${env.NOTIFICATION_EMAIL}", |
| 83 | + subject: "Failed Pipeline: ${currentBuild.fullDisplayName}", |
| 84 | + body: "Pipeline failure. ${env.BUILD_URL}" |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | + } |
| 89 | +} |
| 90 | + |
| 91 | +def execute(String command) { |
| 92 | + if (isUnix()) { |
| 93 | + sh command |
| 94 | + } else { |
| 95 | + bat command |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +String readJsonObject() { |
| 100 | + def jsonObj = readJSON interpolate: true, file: "${env.SOURCE_PROJECT_META_DATA}" |
| 101 | + return jsonObj |
| 102 | +} |
0 commit comments