Guest User

Untitled

a guest
Jan 16th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. pipeline {
  2. agent any
  3. triggers {
  4. cron('@midnight')
  5. }
  6. tools {
  7. maven 'M339'
  8. jdk 'JDK_8.0'
  9. }
  10. stages {
  11. stage('Checkout') {
  12. steps {
  13. checkout scm
  14. }
  15. }
  16.  
  17. stage('Build') {
  18. steps {
  19. sh '''
  20. mvn $SONAR_DEFAULT_MVN_GOAL
  21. '''
  22. }
  23. }
  24.  
  25. stage('SonarQube Analysis') {
  26. steps {
  27. configFileProvider([configFile(fileId: 'add-build-vars.sh', variable: 'ADD_BUILD_VARS')]) {
  28. sh '''
  29. PATH=$PATH:$HOME/bin
  30. export GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
  31. export GIT_URL=`git config remote.origin.url`
  32. source $ADD_BUILD_VARS
  33. '''
  34. }
  35. script {
  36. def props = readProperties file: 'jenkins-build-vars.properties'
  37. echo "jenkins-build-vars.properties=${props}"
  38. withSonarQubeEnv('sonarqube') {
  39. sh "mvn $SONAR_SCANNER_MVN_GOAL -Dsonar.projectName=${props['SONARQUBE_PROJECTKEY']} -Dsonar.projectKey=${props['SONARQUBE_PROJECTKEY']} -Dsonar.branch=${env.BRANCH_NAME}"
  40. }
  41. }
  42.  
  43. }
  44. }
  45. }
  46. }
Add Comment
Please, Sign In to add comment