-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.groovy
44 lines (37 loc) · 1.09 KB
/
utils.groovy
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
/**
* Utility functions for the jenkins pipeline.
* More about groove for Java dev: http://groovy-lang.org/differences.html
*/
/**
* Build docker image in the current context.
* Equivalent for: docker build -t ${tag} .
* @param tag: tag to be applied
* @return
*/
def build(String tag) {
docker.build(tag)
}
/**
* Build docker image in the given context path.
* Equivalent for: docker build -f ci/Dockerfile -t ${tag} .
* @param tag: tag to be applied
* @param contextPath: location of docker context
* @return
*/
def build(String tag, String contextPath) {
docker.build(tag, ' ' + contextPath)
}
/**
* Deploy docker image to docker registry.
* @param imageName: image name
* @param tag: tag to be applied to image
* @param registryUrl: docker registry url
* @param credentials: credentials to docker registry
* @return
*/
def deployImage(String imageName, String tag, String registryUrl, String credentials) {
docker.withRegistry(registryUrl, credentials) {
docker.image(imageName).push(tag)
}
}
return this // this is necessary for the jenkins pipeline load function