You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Jenkinsfile 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // this file only: (c) 2020 Kegan Myers, use allowed under the MIT License
  2. pipeline {
  3. agent any
  4. stages {
  5. stage('build') {
  6. steps {
  7. checkout scm
  8. script {
  9. sh 'git rev-parse HEAD > commit'
  10. def gitCommit = readFile('commit').trim()
  11. def registryHost = "registry.terrible.network"
  12. def imagePath = "terribleplan/folding-at-home-docker-gpu"
  13. // my registry
  14. withCredentials([usernamePassword(credentialsId: 'registry-terrible-network', passwordVariable: 'password', usernameVariable: 'username')]) {
  15. sh "docker login -u '${username}' -p '${password}' 'https://${registryHost}'"
  16. }
  17. // docker hub
  18. withCredentials([usernamePassword(credentialsId: 'docker-hub', passwordVariable: 'password', usernameVariable: 'username')]) {
  19. sh "docker login -u '${username}' -p '${password}'"
  20. }
  21. // my registry
  22. def sourceImage = "${registryHost}/${imagePath}:${gitCommit}"
  23. sh "docker build -t '${sourceImage}' ."
  24. sh "docker tag '${sourceImage}' '${registryHost}/${imagePath}:latest'"
  25. sh "docker push '${registryHost}/${imagePath}:latest'"
  26. // docker hub
  27. sh "docker tag '${sourceImage}' '${imagePath}:${gitCommit}'"
  28. sh "docker push '${imagePath}:${gitCommit}'"
  29. sh "docker tag '${sourceImage}' '${imagePath}:latest'"
  30. sh "docker push '${imagePath}:latest'"
  31. }
  32. }
  33. }
  34. }
  35. }