Jenkinsfile 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. node {
  2. def app
  3. stage('Initialize'){
  4. def dockerHome = tool 'docker'
  5. env.PATH = "${dockerHome}/bin:${env.PATH}"
  6. sh 'usermod -aG docker jenkins'
  7. }
  8. stage('Clone repository') {
  9. /* Let's make sure we have the repository cloned to our workspace */
  10. checkout scm
  11. }
  12. stage('Build image') {
  13. /* This builds the actual image; synonymous to
  14. * docker build on the command line */
  15. app = docker.build("hochzeit:latest")
  16. }
  17. stage('Test image') {
  18. /* Ideally, we would run a test framework against our image.
  19. * For this example, we're using a Volkswagen-type approach ;-) */
  20. app.inside {
  21. sh 'echo "Tests passed"'
  22. }
  23. }
  24. stage('Push image') {
  25. /* Finally, we'll push the image with two tags:
  26. * First, the incremental build number from Jenkins
  27. * Second, the 'latest' tag.
  28. * Pushing multiple tags is cheap, as all the layers are reused. */
  29. docker.withRegistry('https://container.kornbum.dev', 'container-kornblum-dev') {
  30. app.push("${env.BUILD_NUMBER}")
  31. app.push("latest")
  32. }
  33. }
  34. }