forked from Samarpitaa/AlumNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
91 lines (82 loc) · 2.6 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
pipeline {
agent {
docker {
image 'php:7.4-cli'
// volumes:
// - /var/run/docker.sock:/var/run/docker.sock
}
}
stages {
stage('version') {
steps {
sh 'php --version'
}
}
stage('Build') {
steps {
sh 'php -l *.php'
}
}
stage('Install Composer') {
steps {
sh ' curl -sS https://getcomposer.org/installer | php'
}
}
stage('Install Dependencies') {
steps {
sh 'php composer.phar require'
sh 'php composer.phar install && php composer.phar update'
}
}
stage('Install PHPUnit') {
steps {
sh 'curl -L https://phar.phpunit.de/phpunit.phar > phpunit.phar'
sh 'chmod +x phpunit.phar'
sh 'mv phpunit.phar /usr/local/bin/phpunit'
}
}
stage('Test') {
steps {
sh 'phpunit .'
}
}
stage('Docker install') {
steps {
sh 'curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-17.04.0-ce.tgz \
&& tar xzvf docker-17.04.0-ce.tgz \
&& mv docker/docker /usr/local/bin \
&& rm -r docker docker-17.04.0-ce.tgz'
}
}
stage('Deploy to Docker Hub') {
steps {
// Build the Docker image for your PHP website
sh 'docker build -t my-php-website .'
// Tag the Docker image with the Docker Hub repository name
sh 'docker tag my-php-website alumnet/alumnet:latest'
// Push the Docker image to Docker Hub
sh 'docker push alumnet/alumnet:latest'
}
}
// stage('Build Image') {
// steps {
// script {
// def registry = 'alumnet/alumnet'
// def image = 'myphpapp'
// def tag = "${registry}/${image}:${env.BUILD_NUMBER}"
// docker.build("${tag}", '.')
// }
// }
// }
// stage('Push Image') {
// steps {
// script {
// def registry = 'alumnet/alumnet'
// def image = 'myphpapp'
// def tag = "${registry}/${image}:${env.BUILD_NUMBER}"
// sh "docker push ${tag}"
// }
// }
// }
}
}