Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.32 KB | None | 0 0
  1. pipeline {
  2.          agent any
  3.          stages {
  4.                  stage('Checkout') {
  5.                  steps {
  6.                      echo 'Retrieving Jenkinsfile from the github repository.'
  7.                    checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: 'dummy']], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/humblemetsuke/coursework_2']]])
  8.                  }
  9.                  }
  10.                  
  11.         stage('SonarQube') {
  12.     environment {
  13.         scannerHome = tool 'SonarQube'
  14.     }
  15.     steps {
  16.         withSonarQubeEnv('SonarQube') {
  17.             sh "${scannerHome}/bin/sonar-scanner"
  18.         }
  19.         timeout(time: 1, unit: 'HOURS') {
  20.             waitForQualityGate abortPipeline: true
  21.         }
  22.     }
  23. }
  24.  
  25. stage ('build docker image') {
  26.  
  27. steps {
  28. echo 'Beginning to build the docker image.'
  29.  
  30. script {
  31.  
  32. dockerImage= docker.build("coursework_2")
  33.  
  34.          }
  35. }
  36.  
  37. }
  38.  
  39. stage ('push docker image to DockerHub') {
  40.  
  41. steps {
  42. echo 'Beginning to push the built docker image to Dockerhub.'
  43.  
  44. script {
  45.  
  46. withDockerRegistry(credentialsId: 'e1984af9-1751-4825-883a-9194875c8f89', url: '') {
  47.          docker.push("${env.BUILD_NUMBER}")
  48. docker.push(dockerImage)
  49.          }
  50. }
  51.  
  52. }
  53.  
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement