-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
74 lines (49 loc) · 1.97 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
withCredentials([
[
$class : 'UsernamePasswordMultiBinding',
credentialsId : 'artifactory-cloud',
passwordVariable: 'ARTIFACTORY_PASSWORD',
usernameVariable: 'ARTIFACTORY_USERNAME'
]
])
{
node ('Slave')
{
stage('Checkout') {
//first commit
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'anishgithub', url: 'https://github.com/anishpravin/gameoflife.git']]])
}
stage('maven build') {
sh '''
echo $ARTIFACTORY_USERNAME
mvn --version
mvn clean install
'''
}
stage('push gameoflife.war to artifactory') {
sh '''
curl -u$ARTIFACTORY_USERNAME:$ARTIFACTORY_PASSWORD -T $WORKSPACE/gameoflife-web/target/gameoflife.war "https://anish123.jfrog.io/anish123/Gameoflife/pipeline-$BUILD_NUMBER"
'''
}
stage ('build docker image') {
sh '''
docker build -t gameoflife:pipeline-$BUILD_NUMBER $WORKSPACE/gameoflife-web/ --file $WORKSPACE/gameoflife-web/Dockerfile
'''
}
stage ('push gameoflifedocker image') {
withDockerRegistry(credentialsId: 'artifactory-cloud', url: 'https://anish123-gameoflife-docker.jfrog.io') {
sh '''
docker tag gameoflife:pipeline-$BUILD_NUMBER anish123-gameoflife-docker.jfrog.io/gameoflife:pipeline-$BUILD_NUMBER
docker push anish123-gameoflife-docker.jfrog.io/gameoflife:pipeline-$BUILD_NUMBER
'''
}
}
stage ('run docker image') {
sh '''
docker stop gameoflife-pipeline
docker rm gameoflife-pipeline
docker run -d -p 8889:8080 --name gameoflife-pipeline anish123-gameoflife-docker.jfrog.io/gameoflife:pipeline-$BUILD_NUMBER
'''
}
}
}