-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
80 lines (70 loc) · 3.53 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
def buildDockerfile(main_folder, dockerfilePath, image_name, version, changedFiles) {
if (changedFiles.contains(main_folder) || changedFiles.contains('celery_app') || changedFiles.contains('http_server') || changedFiles.contains('document') || changedFiles.contains('docker-entrypoint.sh') || changedFiles.contains('healthcheck.sh') || changedFiles.contains('wait-for-it.sh')) {
echo "Building Dockerfile for ${image_name} with version ${version} (using ${dockerfilePath})"
script {
def image = docker.build(image_name, "-f ${dockerfilePath} .")
docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') {
if (version == 'latest-unstable') {
image.push('latest-unstable')
} else {
image.push('latest')
image.push(version)
}
}
}
}
}
pipeline {
agent any
environment {
// DOCKER_HUB_REPO_PYBK = "lintoai/linto-diarization-pybk" // DEPRECATED
DOCKER_HUB_REPO_PYANNOTE = "lintoai/linto-diarization-pyannote"
DOCKER_HUB_REPO_SIMPLE = "lintoai/linto-diarization-simple"
}
stages {
stage('Docker build for master branch') {
when {
branch 'master'
}
steps {
echo 'Publishing latest'
script {
def changedFiles = sh(returnStdout: true, script: 'git diff --name-only HEAD^ HEAD').trim()
echo "My changed files: ${changedFiles}"
// // DEPRECATED
// version = sh(
// returnStdout: true,
// script: "awk -v RS='' '/#/ {print; exit}' pybk/RELEASE.md | head -1 | sed 's/#//' | sed 's/ //'"
// ).trim()
// buildDockerfile('pybk', 'pybk/Dockerfile', env.DOCKER_HUB_REPO_PYBK, version, changedFiles)
version = sh(
returnStdout: true,
script: "awk -v RS='' '/#/ {print; exit}' simple/RELEASE.md | head -1 | sed 's/#//' | sed 's/ //'"
).trim()
buildDockerfile('simple', 'simple/Dockerfile', env.DOCKER_HUB_REPO_SIMPLE, version, changedFiles)
version = sh(
returnStdout: true,
script: "awk -v RS='' '/#/ {print; exit}' pyannote/RELEASE.md | head -1 | sed 's/#//' | sed 's/ //'"
).trim()
buildDockerfile('pyannote', 'pyannote/Dockerfile', env.DOCKER_HUB_REPO_PYANNOTE, version, changedFiles)
}
}
}
stage('Docker build for next (unstable) branch') {
when {
branch 'next'
}
steps {
echo 'Publishing unstable'
script {
def changedFiles = sh(returnStdout: true, script: 'git diff --name-only HEAD^ HEAD').trim()
echo "My changed files: ${changedFiles}"
version = 'latest-unstable'
// buildDockerfile('pybk', 'pybk/Dockerfile', env.DOCKER_HUB_REPO_PYBK, version, changedFiles) // DEPRECATED
buildDockerfile('simple', 'simple/Dockerfile', env.DOCKER_HUB_REPO_SIMPLE, version, changedFiles)
buildDockerfile('pyannote', 'pyannote/Dockerfile', env.DOCKER_HUB_REPO_PYANNOTE, version, changedFiles)
}
}
}
}
}