-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
39 lines (29 loc) · 1 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
pipeline {
agent any
environment {
BASE_IMAGE="nginx:latest"
TARGET_IMAGE="hleb/nginx-letsencrypt"
DEFAULT_TAG='latest'
GIT_TAG="$GIT_COMMIT".take(8)
TARGET_REGISTRY="$PRIVATE_REGISTRY_HOSTNAME"
PRIVATE_REGISTRY_URL ="$TARGET_REGISTRY:$PRIVATE_REGISTRY_PORT"
// convention
REGISTRY_CREDENTIALS_ID="$TARGET_REGISTRY"
TARGET_IMAGE_TAG="$PRIVATE_REGISTRY_URL/$TARGET_IMAGE:git_$GIT_TAG"
}
stages {
stage('Build') {
steps {
sh 'docker pull $BASE_IMAGE'
script {
newimage = docker.build(env.TARGET_IMAGE_TAG)
withDockerRegistry([credentialsId: env.REGISTRY_CREDENTIALS_ID, url: 'https://'+env.PRIVATE_REGISTRY_URL]) {
newimage.push('latest')
newimage.push(env.GIT_TAG)
newimage.push(env.BRANCH_TAG)
}
}
}
}
}
}