Browse Source

Create pipeline for builds

master
Kegan Myers 7 months ago
parent
commit
3fd7602dce
1 changed files with 39 additions and 0 deletions
  1. 39
    0
      Jenkinsfile

+ 39
- 0
Jenkinsfile View File

@@ -0,0 +1,39 @@
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
+
14
+          // my registry
15
+          withCredentials([usernamePassword(credentialsId: 'registry-terrible-network', passwordVariable: 'password', usernameVariable: 'username')]) {
16
+            sh "docker login -u '${username}' -p '${password}' 'https://${registryHost}'"
17
+          }
18
+          // docker hub
19
+          withCredentials([usernamePassword(credentialsId: 'docker-hub', passwordVariable: 'password', usernameVariable: 'username')]) {
20
+            sh "docker login -u '${username}' -p '${password}'"
21
+          }
22
+
23
+          // my registry
24
+          def sourceImage = "${registryHost}/${imagePath}:${gitCommit}"
25
+          sh "docker build -t '${sourceImage}' ."
26
+          sh "docker tag '${sourceImage}' '${registryHost}/${imagePath}:latest'"
27
+          sh "docker push '${registryHost}/${imagePath}:latest'"
28
+
29
+          // docker hub
30
+          sh "docker tag '${sourceImage}' '${imagePath}:${gitCommit}'"
31
+          sh "docker push '${imagePath}:${gitCommit}'"
32
+          sh "docker tag '${sourceImage}' '${imagePath}:latest'"
33
+          sh "docker push '${imagePath}:latest'"
34
+        }
35
+      }
36
+    }
37
+  }
38
+}
39
+

Loading…
Cancel
Save