forked from romancin/tinymediamanager-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
69 lines (69 loc) · 2.37 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
pipeline {
environment {
registry = "romancin/tinymediamanager"
repository = "tinymediamanager"
withCredentials = 'dockerhub'
registryCredential = 'dockerhub'
}
agent any
stages {
stage('Cloning Git Repository') {
steps {
git url: 'https://github.com/romancin/tinymediamanager-docker.git',
branch: '$BRANCH_NAME'
}
}
stage('Building image and pushing it to the registry (develop)') {
when{
branch 'develop'
}
steps {
script {
def gitbranch = sh(returnStdout: true, script: 'git rev-parse --abbrev-ref HEAD').trim()
def version = readFile('VERSION')
def versions = version.split('\\.')
def major = gitbranch + '-' + versions[0]
def minor = gitbranch + '-' + versions[0] + '.' + versions[1]
def patch = gitbranch + '-' + version.trim()
docker.withRegistry('', registryCredential) {
def image = docker.build("$registry:$gitbranch", "-f Dockerfile .")
image.push()
image.push(major)
image.push(minor)
image.push(patch)
}
}
}
}
stage('Building image and pushing it to the registry (master)') {
when{
branch 'master'
}
steps {
script {
def version = readFile('VERSION')
def versions = version.split('\\.')
def major = versions[0]
def minor = versions[0] + '.' + versions[1]
def patch = version.trim()
docker.withRegistry('', registryCredential) {
def image = docker.build("$registry:latest", "-f Dockerfile .")
image.push()
image.push(major)
image.push(minor)
image.push(patch)
}
}
script {
withCredentials([usernamePassword(credentialsId: 'dockerhub', passwordVariable: 'DOCKERHUB_PASSWORD', usernameVariable: 'DOCKERHUB_USERNAME')]) {
docker.image('sheogorath/readme-to-dockerhub').run('-v $PWD:/data -e DOCKERHUB_USERNAME=$DOCKERHUB_USERNAME -e DOCKERHUB_PASSWORD=$DOCKERHUB_PASSWORD -e DOCKERHUB_REPO_NAME=$repository')
}
}
}
}
}
post {
success {
telegramSend(message: '[Jenkins] - Pipeline CI-tinymediamanager-docker $BUILD_URL finalizado con estado :: $BUILD_STATUS', chatId: -395961814) }
}
}