|
| 1 | +- pipeline: |
| 2 | + name: trigger-fsal-on-new-patch |
| 3 | + node: cico-workspace |
| 4 | + description: >- |
| 5 | + Run fsal-cephfs, fsal-gluster, fsal-gpfs, fsal-rgw on nfs-ganesha. This job is triggered by |
| 6 | + sending a change to |
| 7 | + https://review.gerrithub.io/#/q/project:ffilz/nfs-ganesha for review. |
| 8 | +
|
| 9 | + Note: it is possible to retrigger a test for a change by including recheck |
| 10 | + fsal in a comment on GerritHub. |
| 11 | + project-type: pipeline |
| 12 | + concurrent: true |
| 13 | + allow-manual-triggers: false |
| 14 | + |
| 15 | + scm: |
| 16 | + - ci-tests |
| 17 | + |
| 18 | + discard-old-builds: |
| 19 | + days-to-keep: 14 |
| 20 | + num-to-keep: 14 |
| 21 | + |
| 22 | + builders: |
| 23 | + - get-node |
| 24 | + - shell: !include-raw-verbatim: scripts/fsal-build.sh |
| 25 | + |
| 26 | + triggers: |
| 27 | + - gerrit: |
| 28 | + server-name: nfs-ganesha-gerrithub |
| 29 | + silent: true |
| 30 | + trigger-on: |
| 31 | + - patchset-created-event: |
| 32 | + exclude-drafts: true |
| 33 | + - comment-added-contains-event: |
| 34 | + comment-contains-value: "recheck fsal" |
| 35 | + projects: |
| 36 | + - project-compare-type: PLAIN |
| 37 | + project-pattern: "ffilz/nfs-ganesha" |
| 38 | + branches: |
| 39 | + - branch-pattern: "**" |
| 40 | + branch-compare-type: ANT |
| 41 | + dsl: | |
| 42 | + pipeline { |
| 43 | + agent { label 'cico-workspace' } |
| 44 | +
|
| 45 | + stages { |
| 46 | + stage('Trigger FSAL Jobs in Parallel') { |
| 47 | + steps { |
| 48 | + script { |
| 49 | + def gerritParams = [ |
| 50 | + 'GERRIT_PATCHSET_REVISION', 'GERRIT_REFSPEC', 'GERRIT_PROJECT','GERRIT_HOST' |
| 51 | + ] |
| 52 | +
|
| 53 | + def sharedParams = gerritParams.collect { paramName -> |
| 54 | + string(name: paramName, value: env.getProperty(paramName) ?: '') |
| 55 | + } |
| 56 | +
|
| 57 | + def jobList = ['fsal-cephfs', 'fsal-gluster', 'fsal-gpfs', 'fsal-rgw'] |
| 58 | + def results = [:] |
| 59 | + def messages = ["**FSAL Job Results:**\\n"] |
| 60 | +
|
| 61 | + parallel jobList.collectEntries { job -> |
| 62 | + [(job): { |
| 63 | + def build = build job: job, parameters: sharedParams, propagate: false, wait: true |
| 64 | + results[job] = build |
| 65 | +
|
| 66 | + def msg = '' |
| 67 | + try { |
| 68 | + def jobUrl = build.absoluteUrl |
| 69 | + def artifactUrl = "\${jobUrl}artifact/result_message.txt" |
| 70 | + sh "curl -s -o tmp_result_message_\${job}.txt '\${artifactUrl}'" |
| 71 | + msg = readFile("tmp_result_message_\${job}.txt").trim() |
| 72 | + } catch (Exception e) { |
| 73 | + msg = "**🔴 \${job}: ERROR fetching result_message.txt**" |
| 74 | + } |
| 75 | +
|
| 76 | + messages << msg |
| 77 | + }] |
| 78 | + } |
| 79 | +
|
| 80 | + def finalMessage = messages.join("\\n") |
| 81 | + writeFile file: 'gerrit_message.txt', text: finalMessage |
| 82 | +
|
| 83 | + def notifyFlag = '--notify NONE' // default |
| 84 | + if (finalMessage.contains('FAILED')) { |
| 85 | + notifyFlag = '--notify ALL' |
| 86 | + } |
| 87 | + |
| 88 | + withCredentials([file(credentialsId: 'GERRITHUB_PRIVATE_KEY', variable: 'GERRITHUB_KEY_FILE')]) { |
| 89 | + sh """ |
| 90 | + ssh -i \$GERRITHUB_KEY_FILE -l jenkins-glusterorg -o StrictHostKeyChecking=no -p 29418 \$GERRIT_HOST \\ |
| 91 | + gerrit review \\ |
| 92 | + $notifyFlag \\ |
| 93 | + --message "'$(cat gerrit_message.txt)'" \\ |
| 94 | + --project $GERRIT_PROJECT \\ |
| 95 | + $GERRIT_PATCHSET_REVISION |
| 96 | + ''' |
| 97 | + } |
| 98 | + } |
| 99 | + } |
| 100 | + } |
| 101 | + } |
| 102 | + } |
0 commit comments