Advertisement
GrueMaster

Untitled

Jul 9th, 2019
1,228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 3.15 KB | None | 0 0
  1. #!/usr/bin/groovy
  2.  
  3. def call(mode) {
  4.     def destDir = '/srv/bitstreams'
  5.     def jobList = [:]
  6.     def gbsList = []
  7.     def remote = [:]
  8.     remote.name = 'compute'
  9.     remote.host = 'compute'
  10.     remote.allowAnyHosts = true
  11.  
  12.     if (mode) {
  13.         srchParm = "|fgrep -i ${mode}"
  14.     }
  15.     def tmpList = sh(script: "find hw -name 'filelist_PAR*.txt' -type f ${srchParm}", returnStdout: true).split()
  16.     tmpList.each {
  17.         def tmpFile = findFiles(glob: it)
  18.         if (tmpFile.size()) {
  19.             gbsList.addAll(tmpFile)
  20.         }
  21.     }
  22.     def date = sh (script:'date +%Y%m%d', returnStdout: true).trim()
  23.     def gitTag = sh (script: 'git describe --always --match "v[0-9].*"', returnStdout: true).trim()
  24.     destDir += "/${date}-${gitTag}"
  25.     stage('Stash') {
  26.         stash excludes: 'sw/**', includes: 'hw/**, test/**', name: 'Sira'
  27.     }
  28.     for (int x = 0; x < gbsList.size(); x++) {
  29.         int idx = x
  30.         String gbsName = gbsList[idx].name.minus('filelist_PAR_').minus('.txt')
  31.         String gbsPath = gbsList[idx].path
  32.         jobList[gbsName] = {
  33.             node('RTL') {
  34.                 stage("Build ${gbsName} - test") {
  35.                     unstash 'Sira'
  36.                     try {
  37.                         sh label: "Build ${gbsName}",
  38.                            script: """#!/usr/bin/env bash
  39.                                export DCP_VERSION="a10_gx_pac_ias_1_2_pv"
  40.                                export DCP_LOC="/opt/inteldevstack/\$DCP_VERSION"
  41.                                export OPAE_PLATFORM_ROOT="\$DCP_LOC"
  42.                                export QUARTUS_HOME="/opt/inteldevstack/intelFPGA_pro/quartus"
  43.                                export MTI_HOME="/opt/modelsim-ase"
  44.                                export PATH="\$MTI_HOME/linux:\$MTI_HOME/bin:\$QUARTUS_HOME/bin:\$DCP_LOC/bin:\$PATH"
  45.                                rm -Rf build_*
  46.                                afu_synth_setup -s ${gbsPath} build_${gbsName}
  47.                                cd build_${gbsName}
  48.                                \$OPAE_PLATFORM_ROOT/bin/run.sh -o ${gbsName}.gbs > build_${gbsName}.out
  49.                        """
  50.                     } catch(e) {
  51.                         build_ok = false
  52.                         error "Failed to build ${gbsName}"
  53.                     }
  54.                 }
  55.                 stage("Publish Bitstream"){
  56.                     if (fileExists("build_${gbsName}/${gbsName}.gbs")) {
  57.                         withCredentials([sshUserPrivateKey(credentialsId: '<myKey>', keyFileVariable: 'userKey', passphraseVariable: 'userPass', usernameVariable: 'userName')]) {
  58.                             remote.user = userName
  59.                             remote.identityFile = userKey
  60.                             sshCommand remote: remote, command: "mkdir -p ${destDir}"
  61.                             sshPut remote: remote, from:"build_${gbsName}/${gbsName}.gbs", into: destDir
  62.                         }
  63.                     }
  64.                     zip zipfile: "build_${gbsname}-logs.zip", archive: true, glob: "build_${gbs_name}/build/output_files/**"
  65.                 }
  66.             }
  67.         }
  68.     }
  69.     parallel jobList
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement