Jenkinsfile 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. podTemplate(label: 'node-0', containers: [
  2. containerTemplate(
  3. name: 'jnlp',
  4. image: 'eggsy84/gcp-jenkins-slave-k8s-seed:latest',
  5. ttyEnabled: false,
  6. command: '',
  7. privileged: true,
  8. alwaysPullImage: false,
  9. workingDir: '/home/jenkins',
  10. args: '${computer.jnlpmac} ${computer.name}'
  11. )
  12. ],
  13. volumes: [
  14. secretVolume(mountPath: '/opt/config', secretName: 'gcloud-svc-account'),
  15. hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
  16. persistentVolumeClaim(claimName: 'data-claim-compile', mountPath: '/data'),
  17. ]
  18. ) {
  19. node('node-0') {
  20. stage('Compile') {
  21. sh 'gcloud auth activate-service-account --key-file=/opt/config/gcloud-svc-account.json'
  22. sh 'cd /data && rm -Rf *'
  23. sh 'cd /data && git clone https://github.com/googlecartographer/cartographer_ros'
  24. sh 'cd /data/cartographer_ros && docker build -f jenkins/Dockerfile.kinetic -t kinetic-jenkins-slave --build-arg CACHEBUST=$(date +%s) .'
  25. }
  26. stage('Push') {
  27. sh 'docker tag kinetic-jenkins-slave eu.gcr.io/cartographer-141408/kinetic-jenkins-slave'
  28. sh 'gcloud docker -- push eu.gcr.io/cartographer-141408/kinetic-jenkins-slave'
  29. sh 'cd /data && rm -Rf *'
  30. }
  31. }
  32. }
  33. podTemplate(label: 'node-1', containers: [
  34. containerTemplate(
  35. name: 'jnlp',
  36. image: 'eu.gcr.io/cartographer-141408/kinetic-jenkins-slave:latest',
  37. ttyEnabled: false,
  38. command: '',
  39. privileged: true,
  40. alwaysPullImage: true,
  41. workingDir: '/home/jenkins',
  42. args: '${computer.jnlpmac} ${computer.name}'
  43. )
  44. ],
  45. volumes: [
  46. secretVolume(mountPath: '/opt/config', secretName: 'gcloud-svc-account'),
  47. hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
  48. persistentVolumeClaim(claimName: 'data-claim-compile', mountPath: '/data'),
  49. ]
  50. ) {
  51. node('node-1') {
  52. stage('Run Fetch Pipeline') {
  53. sh 'gcloud auth activate-service-account --key-file=/opt/config/gcloud-svc-account.json'
  54. sh 'GOOGLE_APPLICATION_CREDENTIALS="/opt/config/gcloud-svc-account.json" GOOGLE_CLOUD_DISABLE_GRPC=True python /worker.py --worker_id 0 --num_workers 1 --pipeline_id fetch'
  55. }
  56. }
  57. }
  58. podTemplate(label: 'node-2', containers: [
  59. containerTemplate(
  60. name: 'jnlp',
  61. image: 'eu.gcr.io/cartographer-141408/kinetic-jenkins-slave:latest',
  62. ttyEnabled: false,
  63. command: '',
  64. privileged: true,
  65. alwaysPullImage: true,
  66. workingDir: '/home/jenkins',
  67. args: '${computer.jnlpmac} ${computer.name}'
  68. )
  69. ],
  70. volumes: [
  71. secretVolume(mountPath: '/opt/config', secretName: 'gcloud-svc-account'),
  72. hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
  73. persistentVolumeClaim(claimName: 'data-claim-compile', mountPath: '/data'),
  74. ]
  75. ) {
  76. node('node-2') {
  77. stage('Run Backpack Pipeline') {
  78. sh 'gcloud auth activate-service-account --key-file=/opt/config/gcloud-svc-account.json'
  79. sh 'GOOGLE_APPLICATION_CREDENTIALS="/opt/config/gcloud-svc-account.json" GOOGLE_CLOUD_DISABLE_GRPC=True python /worker.py --worker_id 0 --num_workers 1 --pipeline_id backpack'
  80. }
  81. }
  82. }
  83. podTemplate(label: 'node-3', containers: [
  84. containerTemplate(
  85. name: 'jnlp',
  86. image: 'eu.gcr.io/cartographer-141408/kinetic-jenkins-slave:latest',
  87. ttyEnabled: false,
  88. command: '',
  89. privileged: true,
  90. alwaysPullImage: true,
  91. workingDir: '/home/jenkins',
  92. args: '${computer.jnlpmac} ${computer.name}'
  93. )
  94. ],
  95. volumes: [
  96. secretVolume(mountPath: '/opt/config', secretName: 'gcloud-svc-account'),
  97. hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
  98. persistentVolumeClaim(claimName: 'data-claim-compile', mountPath: '/data'),
  99. ]
  100. ) {
  101. node('node-3') {
  102. stage('Run Toru Pipeline') {
  103. sh 'gcloud auth activate-service-account --key-file=/opt/config/gcloud-svc-account.json'
  104. sh 'GOOGLE_APPLICATION_CREDENTIALS="/opt/config/gcloud-svc-account.json" GOOGLE_CLOUD_DISABLE_GRPC=True python /worker.py --worker_id 0 --num_workers 1 --pipeline_id toru'
  105. }
  106. }
  107. }