Create pipeline for builds
This commit is contained in:
parent
79b0e66ada
commit
3fd7602dce
39
Jenkinsfile
vendored
Normal file
39
Jenkinsfile
vendored
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
// this file only: (c) 2020 Kegan Myers, use allowed under the MIT License
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
stages {
|
||||||
|
stage('build') {
|
||||||
|
steps {
|
||||||
|
checkout scm
|
||||||
|
script {
|
||||||
|
sh 'git rev-parse HEAD > commit'
|
||||||
|
def gitCommit = readFile('commit').trim()
|
||||||
|
def registryHost = "registry.terrible.network"
|
||||||
|
def imagePath = "terribleplan/folding-at-home-docker-gpu"
|
||||||
|
|
||||||
|
// my registry
|
||||||
|
withCredentials([usernamePassword(credentialsId: 'registry-terrible-network', passwordVariable: 'password', usernameVariable: 'username')]) {
|
||||||
|
sh "docker login -u '${username}' -p '${password}' 'https://${registryHost}'"
|
||||||
|
}
|
||||||
|
// docker hub
|
||||||
|
withCredentials([usernamePassword(credentialsId: 'docker-hub', passwordVariable: 'password', usernameVariable: 'username')]) {
|
||||||
|
sh "docker login -u '${username}' -p '${password}'"
|
||||||
|
}
|
||||||
|
|
||||||
|
// my registry
|
||||||
|
def sourceImage = "${registryHost}/${imagePath}:${gitCommit}"
|
||||||
|
sh "docker build -t '${sourceImage}' ."
|
||||||
|
sh "docker tag '${sourceImage}' '${registryHost}/${imagePath}:latest'"
|
||||||
|
sh "docker push '${registryHost}/${imagePath}:latest'"
|
||||||
|
|
||||||
|
// docker hub
|
||||||
|
sh "docker tag '${sourceImage}' '${imagePath}:${gitCommit}'"
|
||||||
|
sh "docker push '${imagePath}:${gitCommit}'"
|
||||||
|
sh "docker tag '${sourceImage}' '${imagePath}:latest'"
|
||||||
|
sh "docker push '${imagePath}:latest'"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue