| @NonCPS |
| def getSlackMessage() { |
| def message = "Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}> of <https://git.eclipse.org/c/hawk/hawk.git/log/?h=${env.BRANCH_NAME}|${currentBuild.fullProjectName}> " |
| |
| message += (currentBuild.currentResult == "SUCCESS" ? "passed" : "failed") + " in ${currentBuild.durationString}\n\n" |
| for (changeSet in currentBuild.changeSets) { |
| for (entry in changeSet.items) { |
| message += "`${entry.commitId.take(7)}` ${entry.msg} - ${entry.author}\n" |
| } |
| } |
| return message |
| } |
| |
| pipeline { |
| agent { |
| kubernetes { |
| label 'hawk-pod' |
| yaml """ |
| apiVersion: v1 |
| kind: Pod |
| spec: |
| containers: |
| - name: maven |
| image: maven:3.6.1-jdk-8 |
| command: |
| - cat |
| tty: true |
| resources: |
| limits: |
| memory: "4Gi" |
| cpu: "1" |
| requests: |
| memory: "4Gi" |
| cpu: "1" |
| env: |
| - name: "MAVEN_OPTS" |
| value: "-Duser.home=/home/jenkins -Xmx512m -Xms256m" |
| - name: "HOME" |
| value: "/home/jenkins" |
| volumeMounts: |
| - name: jenkins-home |
| mountPath: /home/jenkins |
| readOnly: false |
| - name: settings-xml |
| mountPath: /home/jenkins/.m2/settings.xml |
| subPath: settings.xml |
| readOnly: true |
| - name: settings-security-xml |
| mountPath: /home/jenkins/.m2/settings-security.xml |
| subPath: settings-security.xml |
| readOnly: true |
| - name: toolchains-xml |
| mountPath: /home/jenkins/.m2/toolchains.xml |
| subPath: toolchains.xml |
| readOnly: true |
| - name: m2-repo |
| mountPath: /home/jenkins/.m2/repository |
| - name: volume-known-hosts |
| mountPath: /home/jenkins/.ssh |
| - name: jnlp |
| volumeMounts: |
| - name: volume-known-hosts |
| mountPath: /home/jenkins/.ssh |
| volumes: |
| - name: jenkins-home |
| emptyDir: |
| medium: "" |
| - name: settings-xml |
| secret: |
| secretName: m2-secret-dir |
| items: |
| - key: settings.xml |
| path: settings.xml |
| - name: settings-security-xml |
| secret: |
| secretName: m2-secret-dir |
| items: |
| - key: settings-security.xml |
| path: settings-security.xml |
| - name: m2-repo |
| emptyDir: {} |
| - name: toolchains-xml |
| configMap: |
| name: m2-dir |
| items: |
| - key: toolchains.xml |
| path: toolchains.xml |
| - name: volume-known-hosts |
| configMap: |
| name: known-hosts |
| """ |
| } |
| } |
| stages { |
| stage('Core without tests') { |
| when { |
| anyOf { |
| changeset 'core/plugins/**' |
| changeset 'core/tests/**' |
| changeset 'core/releng/org.eclipse.hawk.targetplatform/**' |
| changeset 'greycat/**' |
| changeset 'server/**' |
| changeset 'pom.xml' |
| changeset 'pom-plain.xml' |
| expression { return currentBuild.number == 1 } |
| } |
| } |
| steps { |
| container('maven') { |
| sh 'cd core && mvn -B --quiet clean install -DskipTests --toolchains jenkins-toolchains.xml' |
| } |
| } |
| } |
| stage('Greycat without tests') { |
| when { |
| anyOf { |
| changeset 'core/plugins/**' |
| changeset 'core/tests/**' |
| changeset 'core/releng/org.eclipse.hawk.targetplatform/**' |
| changeset 'greycat/**' |
| changeset 'server/**' |
| changeset 'pom.xml' |
| changeset 'pom-plain.xml' |
| expression { return currentBuild.number == 1 } |
| } |
| } |
| steps { |
| container('maven') { |
| sh 'cd greycat && mvn -B --quiet clean install -DskipTests --toolchains ../core/jenkins-toolchains.xml' |
| } |
| } |
| } |
| stage('Tycho') { |
| when { |
| anyOf { |
| changeset 'core/plugins/**' |
| changeset 'core/tests/**' |
| changeset 'core/releng/org.eclipse.hawk.targetplatform/**' |
| changeset 'greycat/**' |
| changeset 'server/**' |
| changeset 'pom.xml' |
| changeset 'pom-plain.xml' |
| expression { return currentBuild.number == 1 } |
| } |
| } |
| steps { |
| container('maven') { |
| sh 'cd server && mvn -B --quiet clean install -P signjars -DfailIfNoTests=false --toolchains ../core/jenkins-toolchains.xml' |
| } |
| } |
| post { always { junit '**/TEST-*.xml' } } |
| } |
| stage('Downloads') { |
| when { |
| allOf { |
| branch 'master' |
| anyOf { |
| changeset 'core/plugins/**' |
| changeset 'core/tests/**' |
| changeset 'core/releng/org.eclipse.hawk.targetplatform/**' |
| changeset 'greycat/**' |
| changeset 'server/**' |
| changeset 'pom.xml' |
| changeset 'pom-plain.xml' |
| expression { return currentBuild.number == 1 } |
| } |
| } |
| } |
| steps { |
| lock('download-area') { |
| sshagent (['projects-storage.eclipse.org-bot-ssh']) { |
| sh 'server/deploy-downloads.sh' |
| } |
| } |
| } |
| } |
| } |
| post { |
| success{ |
| slackSend (channel: '#ci-notifications', botUser: true, color: '#00FF00', message: getSlackMessage()) |
| } |
| failure { |
| slackSend (channel: '#ci-notifications', botUser: true, color: '#FF0000', message: getSlackMessage()) |
| } |
| changed { |
| emailext(body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}", |
| recipientProviders: [[ |
| $class: "DevelopersRecipientProvider", |
| $class: "RequesterRecipientProvider" |
| ]], |
| subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}") |
| } |
| } |
| } |