Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Project_jenkins_php
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MUNIER Florian
Project_jenkins_php
Commits
d709f52a
Commit
d709f52a
authored
2 years ago
by
MUNIER Florian
Browse files
Options
Downloads
Patches
Plain Diff
[add] add delivery dockerfile & checktva file
parent
391122b7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Jenkinsfile
+79
-11
79 additions, 11 deletions
Jenkinsfile
src/Dockerfile
+9
-0
9 additions, 0 deletions
src/Dockerfile
src/checktva.php
+13
-0
13 additions, 0 deletions
src/checktva.php
src/code.php
+1
-2
1 addition, 2 deletions
src/code.php
with
102 additions
and
13 deletions
Jenkinsfile
+
79
−
11
View file @
d709f52a
pipeline
{
environment
{
QUALITY_GATE
=
'10'
CODE_COVERAGE
=
'50'
QUALITY_DOCKER
=
'5'
}
agent
any
stages
{
stage
(
'checkout'
)
{
...
...
@@ -9,20 +15,82 @@ pipeline {
}
}
stage
(
'test'
)
{
echo
"Phase 2 : agent Dockerfile"
agent
{
dockerfile
{
dir
'build/docker/phpunit'
filename
'Dockerfile'
stage
(
'tests'
)
{
parallel
{
stage
(
'hadolint'
)
{
// Phase : agent Dockerfile im age hadolint
agent
{
docker
{
image
'docker.io/hadolint/hadolint:v2.12.0-alpine'
}
}
steps
{
echo
'Phase : création hadolint.json'
sh
'touch hadolin.json'
echo
'Phase : exécution hadolint sur les deux Dockerfile du'
sh
'find ./ -iname "Dockerfile" | xargs hadolint -f json | tee -a hadolint.json'
recordIssues
qualityGates:
[[
threshold:
QUALITY_DOCKER
,
type:
'TOTAL'
,
unstable:
false
]],
tools:
[
hadoLint
(
pattern:
'hadolint.json'
)]
sh
'rm hadolint.json'
}
}
stage
(
'tests statiques'
)
{
// "Phase 2 : agent Dockerfile"
agent
{
dockerfile
{
dir
'build/docker/phpunit'
filename
'Dockerfile'
}
}
steps
{
echo
"Phase 3 : préparation de l'environnement"
sh
'ls -l'
sh
'make clean'
sh
'ls -l'
echo
"Phase 4: Réalisation des tests statiques"
sh
'make qa'
echo
"Phase 5: Publication des erreurs checkstyle/pmd avec un seuil a 10"
recordIssues
qualityGates:
[[
threshold:
QUALITY_GATE
,
type:
'TOTAL'
,
unstable:
false
]],
tools:
[
pmdParser
(
pattern:
'build/logs/pmd.xml'
),
phpCodeSniffer
(
pattern:
'build/logs/checkstyle.xml'
)]
}
}
stage
(
'Tests unitaires'
)
{
agent
{
dockerfile
{
dir
'build/docker/phpunit'
filename
'Dockerfile'
}
}
steps
{
echo
"Phase 6 : préparation de l'environnement"
sh
'ls -l'
sh
'make test'
sh
'ls -l'
echo
"Phase 7: Réalisation des tests unitaires"
sh
'make qa'
echo
"Phase 8 : publication du résultat des tests junit"
xunit
checksName:
''
,
tools:
[
PHPUnit
(
excludesPattern:
''
,
pattern:
'build/logs/junit.xml'
,
stopProcessingIfError:
true
)]
echo
"Phase 9 : publication de la couverture de code"
clover
(
cloverReportDir:
'build/coverage'
,
cloverReportFileName:
'coverage.xml'
,
healthyTarget:
[
methodCoverage:
70
,
conditionalCoverage:
80
,
statementCoverage:
CODE_COVERAGE
],
unhealthyTarget:
[
methodCoverage:
50
,
conditionalCoverage:
50
,
statementCoverage:
50
],
failingTarget:
[
methodCoverage:
0
,
conditionalCoverage:
0
,
statementCoverage:
0
])
}
}
}
}
stage
(
'deploy'
)
{
agent
any
steps
{
echo
"Phase 3 : préparation de l'environnement"
sh
'ls -l'
sh
'make clean'
sh
'ls -l'
echo
"Phase : Script de construction l'image numérotée"
echo
"Phase : Script de publication de l'imagesur le registre privé"
script
{
docker
.
withRegistry
(
'https://gitlab.imt-atlantique.fr/f21munie/project_jenkins_php/container_registry'
)
{
docker
.
build
(
"checktva:${env.BUILD_ID}"
,
"./src"
).
push
()
}
}
}
}
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
src/Dockerfile
0 → 100644
+
9
−
0
View file @
d709f52a
FROM
php:8.0-cli
COPY
code.php /app/code.php
COPY
checktva.php /app/checktva.php
WORKDIR
/app
CMD
[ "php", "./checktva.php" ]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/checktva.php
0 → 100644
+
13
−
0
View file @
d709f52a
<?php
require
"code.php"
;
if
(
!
isset
(
$argv
[
3
]))
{
exit
(
"Usage: php "
.
basename
(
__FILE__
)
.
" <NAME> <TYPE> <PRICE>
\n
"
);
}
try
{
$product
=
new
Product
(
$argv
[
1
],
$argv
[
2
],
$argv
[
3
]);
$product
->
computeTVA
();
echo
" OK TVA calculated
\n
"
;
}
catch
(
\Exception
|
TypeError
$e
)
{
echo
" KO TVA not calculated "
,
$e
->
getMessage
(),
"
\n
"
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/code.php
+
1
−
2
View file @
d709f52a
<?php
namespace
App\Entity
;
<?php
declare
(
strict_types
=
1
);
class
Product
{
const
FOOD_PRODUCT
=
'food'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment