-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkins.jenkins
57 lines (48 loc) · 1.65 KB
/
Jenkins.jenkins
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
#!groovy
// Check ub1 properties
properties([disableConcurrentBuilds()])
def imageName = "rkonovalov/jfilter-samples:tested"
pipeline {
agent {
label "master"
}
//triggers { pollSCM('* * * * *') }
options {
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10'))
timestamps()
}
stages {
stage('Test') {
steps {
echo " ============== start Tests =================="
sh "mvn test"
}
}
stage('Build') {
steps {
echo " ============== start Maven build =================="
sh "mvn -B -Dmaven.test.skip=true clean package"
}
}
stage("docker login") {
steps {
echo " ============== docker login =================="
withCredentials([usernamePassword(credentialsId: 'dockerhub_rkonovalov', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
build job: 'docker-login', parameters: [[$class: 'StringParameterValue', name: 'username', value: "$USERNAME"], [$class: 'StringParameterValue', name: 'password', value: "$PASSWORD"]]
}
}
}
stage("create docker image") {
steps {
echo " ============== start building image =================="
sh "docker build -t ${imageName} . "
}
}
stage("docker push") {
steps {
echo " ============== start pushing image =================="
sh "docker push ${imageName}"
}
}
}
}