pipeline { agent { kubernetes { label 'xtext-build-pod' defaultContainer 'xtext-buildenv' yaml ''' apiVersion: v1 kind: Pod spec: containers: - name: jnlp image: 'eclipsecbi/jenkins-jnlp-agent' args: ['\$(JENKINS_SECRET)', '\$(JENKINS_NAME)'] volumeMounts: - mountPath: /home/jenkins/.ssh name: volume-known-hosts - name: xtext-buildenv image: docker.io/smoht/xtext-buildenv:0.7 tty: true volumeMounts: - name: settings-xml mountPath: /home/jenkins/.m2/settings.xml subPath: settings.xml readOnly: true - name: m2-repo mountPath: /home/jenkins/.m2/repository - name: volume-known-hosts mountPath: /home/jenkins/.ssh volumes: - name: volume-known-hosts configMap: name: known-hosts - name: settings-xml configMap: name: m2-dir items: - key: settings.xml path: settings.xml - name: m2-repo emptyDir: {} ''' } } options { buildDiscarder(logRotator(numToKeepStr:'15')) disableConcurrentBuilds() } // https://jenkins.io/doc/book/pipeline/syntax/#triggers triggers { pollSCM('H/5 * * * *') } // Build stages stages { stage('Checkout') { steps { checkout scm } } stage('Gradle Build') { steps { sh './1-gradle-build.sh' step([$class: 'JUnitResultArchiver', testResults: '**/build/test-results/test/*.xml']) } } stage('Maven Build') { steps { sh './2-maven-build.sh' } } } post { success { archiveArtifacts artifacts: 'build/**' } changed { script { def envName = '' if (env.JENKINS_URL.contains('ci.eclipse.org/xtext')) { envName = ' (JIPP)' } else if (env.JENKINS_URL.contains('jenkins.eclipse.org/xtext')) { envName = ' (CBI)' } else if (env.JENKINS_URL.contains('typefox.io')) { envName = ' (TF)' } def curResult = currentBuild.currentResult def color = '#00FF00' if (curResult == 'SUCCESS' && currentBuild.previousBuild != null) { curResult = 'FIXED' } else if (curResult == 'UNSTABLE') { color = '#FFFF00' } else if (curResult == 'FAILURE') { color = '#FF0000' } slackSend message: "${curResult}: <${env.BUILD_URL}|${env.JOB_NAME}#${env.BUILD_NUMBER}${envName}>", botUser: true, channel: 'xtext-builds', color: "${color}" } } } }