Groovy web console

subscribe to the feed Subscribe
to this
site
nm (via #groovywebconsole)
tweet this snippet Tweet
this
script

nm

Published 2 weeks ago by nm with tags jkljlk
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
pipeline1: 
def buildColor
def syncCodeSuccessfully = false
def bbqSuccessfully = false

node('dbc') {
try {
    
stage('sync code')
        {
            echo 'Sync-ing code'

//ForceCleanImpl SyncOnlyImpl
checkout([$class: 'PerforceScm', credential: '6b1af277-fb63-4cec-af80-15233943f34f', populate: [$class: 'ForceCleanImpl', have: false, parallel: [enable: false, minbytes: '1024', minfiles: '1', path: '/usr/local/bin/p4', threads: '4'], pin: '', quiet: true], workspace: [$class: 'ManualWorkspaceImpl', charset: 'none', name: 'jenkins-${NODE_NAME}-${JOB_NAME}', pinHost: false, spec: [allwrite: false, backup: false, clobber: false, compress: false, line: 'LOCAL', locked: false, modtime: false, rmdir: false, serverID: '', streamName: '', type: 'WRITABLE', view: '''//depot/bora/vim-main/... //jenkins-${NODE_NAME}-${JOB_NAME}/bora/...
//depot/scons/vim-main/... //jenkins-${NODE_NAME}-${JOB_NAME}/scons/...
//depot/vmkdrivers/vim-main/... //jenkins-${NODE_NAME}-${JOB_NAME}/vmkdrivers/...
//depot/vcqe/vim-main/... //jenkins-${NODE_NAME}-${JOB_NAME}/vcqe/...
//depot/vim-clients/vim-main/... //jenkins-${NODE_NAME}-${JOB_NAME}/vim-clients/...
//depot/applmgmt/vim-main/... //jenkins-${NODE_NAME}-${JOB_NAME}/applmgmt/...
//depot/vsphere-client-modules/vim-main/... //jenkins-${NODE_NAME}-${JOB_NAME}/vsphere-client-modules/...
//depot/cls/vim-main/... //jenkins-${NODE_NAME}-${JOB_NAME}/cls/...
//depot/manifest/vim-main/... //jenkins-${NODE_NAME}-${JOB_NAME}/manifest/...
//contrib/gmsl/gmsl-1-1-5/... //jenkins-${NODE_NAME}-${JOB_NAME}/gmsl/...
//depot/bbq/vim-main/... //jenkins-${NODE_NAME}-${JOB_NAME}/bbq/...
//depot/mc/vim-main/... //jenkins-${NODE_NAME}-${JOB_NAME}/mc/...
//depot/vsan-mgmt-ui/vim-main/... //jenkins-${NODE_NAME}-${JOB_NAME}/vsan-mgmt-ui/...
//depot/lotus/vim-main/... //jenkins-${NODE_NAME}-${JOB_NAME}/lotus/...''']]])    
syncCodeSuccessfully = true


        } 
        
stage('Execute bbq cmd')
        {
            def bbq1 = false
            def bbq2 = false
            parallel (
                UUT_SUPPORT: {  
                    sh 'cd $WORKSPACE; chmod 777 scons/vtools/linux/python-2.7.py; sed -i -- \'s/lin32/lin64/g\' scons/vtools/linux/python-2.7.py; chmod 777 scons/bin/scons; sed -i -- \'s/lin32/lin64/g\' scons/bin/scons '
                    sh 'echo -e \'#!/bin/bash\\nexport VMW_BUILD_TYPE=obj\\nexport VMW_PRODUCT=vcenter\\nexport VMW_ARCHITECTURE=x64\\nexport VMW_SOURCE=$WORKSPACE\\nexport VMW_BOD=$WORKSPACE/BOD\\nexport VCENTER_BUILD_DEBUG_BINARIES=0\\n$WORKSPACE/bbq/bbq install.vpxd-uut-support-build\' > $WORKSPACE/execute.sh'
                    sh 'cd $WORKSPACE; chmod 777 execute*; ./execute.sh'
                        },
                VPXD: { 
                    sh 'cd $WORKSPACE; chmod 777 scons/vtools/linux/python-2.7.py; sed -i -- \'s/lin32/lin64/g\' scons/vtools/linux/python-2.7.py; chmod 777 scons/bin/scons; sed -i -- \'s/lin32/lin64/g\' scons/bin/scons '
                    sh 'echo -e \'#!/bin/bash\\nexport VMW_BUILD_TYPE=obj\\nexport VMW_PRODUCT=vcenter\\nexport VMW_ARCHITECTURE=x64\\nexport VMW_SOURCE=$WORKSPACE\\nexport VMW_BOD=$WORKSPACE/BOD\\nexport VCENTER_BUILD_DEBUG_BINARIES=0\\n$WORKSPACE/bbq/bbq -- install.vpxd\' > $WORKSPACE/execute1.sh'
                    sh 'cd $WORKSPACE; chmod 777 execute*; ./execute1.sh'
                        }
                        )

            
            if(bbq1 && bbq2){
   bbqSuccessfully = true
                
            }
        }
        
stage('Run UUT')
        {
        sh 'cd $WORKSPACE; bora/support/uutTools/utRunAll -s bora/vpx --continue | tee executionLog.txt'
        }
        sh 'cd $WORKSPACE; grep \'STATUS: \' executionLog.txt > $WORKSPACE/commandResult'
        result = readFile('commandResult').trim()
        if(!result.contains("errored")){
        currentBuild.result = 'SUCCESS'
        buildColor = 'good'
        }else
        {
        currentBuild.result = 'FAILURE'
        buildColor = 'bad'
  sh 'cd $WORKSPACE; sed \'/Failing tests/,/STATUS:/!d\' executionLog.txt > $WORKSPACE/failTests'
  result = readFile('failTests').trim()
        }
    } catch (err) {
        echo "Failed: ${err}"
    } finally {
        stage('slack message')
        {
          if(!syncCodeSuccessfully){
    def consoleLog = "${JENKINS_URL}/job/${JOB_NAME}/${BUILD_NUMBER}/console"
          responseMsg = "UUT-vim-main Status: FAILURE\nPipeline execution failed at code sync-ing stage\nResults: ${consoleLog} "
          slackSend channel: '#trial', color: buildColor, message: responseMsg, teamDomain: 'vmware', token: 'UTv6l1jk84NtnVzOMI7jQJq0'
     }else
    if(!bbqSuccessfully){
          def consoleLog = "${JENKINS_URL}/job/${JOB_NAME}/${BUILD_NUMBER}/console"
          currentBuild.displayName = "#$P4_CHANGELIST"
          responseMsg = "UUT-vim-main Status: FAILURE\nChangeset: $P4_CHANGELIST\nPipeline execution failed at bbq execution\nResults: ${consoleLog} "
          slackSend channel: '#trial', color: buildColor, message: responseMsg, teamDomain: 'vmware', token: 'UTv6l1jk84NtnVzOMI7jQJq0'     
    }else{
           currentBuild.displayName = "#$P4_CHANGELIST"
     def duration = currentBuild.durationString.split(' ');
     def finalDuration = duration[0]+duration[1]+" "+ duration[2]+duration[3];
     def consoleLog = "${JENKINS_URL}job/${JOB_NAME}/${BUILD_NUMBER}/console"
           responseMsg = "UUT-vim-main Status: ${currentBuild.result} \n${result} \nTime-Taken:  ${finalDuration} \nChangeset: $P4_CHANGELIST\nResults: ${consoleLog}"
           slackSend channel: '#trial', color: buildColor, message: responseMsg , teamDomain: 'vmware', token: 'UTv6l1jk84NtnVzOMI7jQJq0'
           sh 'cd $WORKSPACE; rm -rf executionLog.txt; rm -rf commandResult; rm -rf execute*; rm -rf failTests '
           }
        }           
    }  
    
}