-
Notifications
You must be signed in to change notification settings - Fork 14
/
Jenkinsfile
72 lines (62 loc) · 2.89 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
def buildDockerfile(main_folder, dockerfilePath, image_name, version, changedFiles) {
if (changedFiles.contains(main_folder) || changedFiles.contains('celery_app') || changedFiles.contains('http_server') || changedFiles.contains('websocket') || changedFiles.contains('document')) {
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_KALDI = "lintoai/linto-stt-kaldi"
DOCKER_HUB_REPO_WHISPER = "lintoai/linto-stt-whisper"
}
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}"
version_kaldi = sh(
returnStdout: true,
script: "awk -v RS='' '/#/ {print; exit}' kaldi/RELEASE.md | head -1 | sed 's/#//' | sed 's/ //'"
).trim()
version_whisper = sh(
returnStdout: true,
script: "awk -v RS='' '/#/ {print; exit}' whisper/RELEASE.md | head -1 | sed 's/#//' | sed 's/ //'"
).trim()
buildDockerfile('kaldi', 'kaldi/Dockerfile', env.DOCKER_HUB_REPO_KALDI, version_kaldi, changedFiles)
buildDockerfile('whisper', 'whisper/Dockerfile.ctranslate2', env.DOCKER_HUB_REPO_WHISPER, version_whisper, 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('kaldi', 'kaldi/Dockerfile', env.DOCKER_HUB_REPO_KALDI, version, changedFiles)
buildDockerfile('whisper', 'whisper/Dockerfile.ctranslate2', env.DOCKER_HUB_REPO_WHISPER, version, changedFiles)
}
}
}
}
}