-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsFile
More file actions
63 lines (58 loc) · 1.78 KB
/
JenkinsFile
File metadata and controls
63 lines (58 loc) · 1.78 KB
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
import com.cloudbees.plugins.credentials.impl.*;
import com.cloudbees.plugins.credentials.*;
import com.cloudbees.plugins.credentials.domains.*;
pipeline
{
environment
{
GIT_CREDENTIALS_ID = "GIT_CREDENTIALS"
GIT_REPOSITORY = 'https://gitlab.com/Geeks.Microservices/AccessHub.git'
IMAGE = "${CONTIANER_REPOSITORY_URL}:v_${BUILD_NUMBER}"
}
agent any
stages
{
stage('Prepare credentials')
{
steps
{
script
{
def git_credentials = (Credentials) new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL,GIT_CREDENTIALS_ID, "description", "matt@geeks.ltd.uk", "G!7L@62017")
SystemCredentialsProvider.getInstance().getStore().removeCredentials(Domain.global(), git_credentials)
SystemCredentialsProvider.getInstance().getStore().addCredentials(Domain.global(), git_credentials)
}
}
}
stage('Clone sources')
{
steps
{
script
{
git credentialsId: GIT_CREDENTIALS_ID, url: GIT_REPOSITORY
}
}
}
stage('Build the source code')
{
steps
{
script
{
bat "docker build -t $IMAGE -f Build.Dockerfile --build-arg BUILD_NUMBER=$BUILD_NUMBER --build-arg HUB_SERVICE_URL=$HUB_SERVICE_URL ."
}
}
}
}
post
{
success
{
script
{
bat "docker rmi $IMAGE | true"
}
}
}
}