-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathJenkinsfile
executable file
·39 lines (31 loc) · 1.05 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
def CONTAINER_NAME="neoms"
def CONTAINER_TAG="latest"
node {
stage('Initialize')
{
def dockerHome = tool 'mydocker'
env.PATH = "${dockerHome}/bin:${env.PATH}"
}
stage('Checkout')
{
checkout scm
}
stage('Build Image'){
imageBuild(CONTAINER_NAME, CONTAINER_TAG)
}
stage('Push to Docker Registry'){
withCredentials([usernamePassword(credentialsId: 'docker_registry', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
pushToImage(CONTAINER_NAME, CONTAINER_TAG, USERNAME, PASSWORD)
}
}
}
def imageBuild(containerName, tag){
sh "docker build -t $containerName:$tag -t $containerName --pull --no-cache ."
echo "Image build complete"
}
def pushToImage(containerName, tag, dockerUser, dockerPassword){
sh "docker login -u $dockerUser -p $dockerPassword https://registry.tiniyo.com"
sh "docker tag $containerName:$tag registry.tiniyo.com/$containerName:$tag"
sh "docker push registry.tiniyo.com/$containerName:$tag"
echo "Image push complete"
}