Advertisement
PandaAcademy

Docker Push pipeline

Oct 7th, 2023 (edited)
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. def imageName="192.168.44.44:8082/docker_registry/frontend"
  2. def dockerTag=""
  3. def dockerRegistry="https://192.168.44.44:8082"
  4. def registryCredentials="artifactory"
  5.  
  6. pipeline {
  7. agent {
  8. label 'agent'
  9. }
  10.  
  11. environment {
  12. PIP_BREAK_SYSTEM_PACKAGES = 1
  13. scannerHome = tool 'SonarQube'
  14. }
  15.  
  16. stages {
  17. stage('Get Code') {
  18. steps {
  19. git branch: 'jenkinsfile', url: 'https://github.com/Panda-Academy-Core-2-0/Frontend'
  20. }
  21. }
  22.  
  23. stage('Unit tests') {
  24. steps {
  25. sh "pip3 install -r requirements.txt"
  26. sh "python3 -m pytest --cov=. --cov-report xml:test-results/coverage.xml --junitxml=test-results/pytest-report.xml"
  27. }
  28. }
  29.  
  30. stage('Sonarqube analysis') {
  31. steps {
  32. withSonarQubeEnv('SonarQube') {
  33. sh "${scannerHome}/bin/sonar-scanner"
  34. }
  35. }
  36. }
  37.  
  38. stage('Build application image') {
  39. steps {
  40. script {
  41. dockerTag = "RC-${env.BUILD_ID}"
  42. applicationImage = docker.build("$imageName:$dockerTag")
  43. }
  44. }
  45. }
  46.  
  47. stage ('Pushing image to docker registry') {
  48. steps {
  49. script {
  50. docker.withRegistry("$dockerRegistry", "$registryCredentials") {
  51. applicationImage.push()
  52. applicationImage.push('latest')
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement