Skip to content
Snippets Groups Projects
Commit d709f52a authored by MUNIER Florian's avatar MUNIER Florian
Browse files

[add] add delivery dockerfile & checktva file

parent 391122b7
Branches
No related tags found
No related merge requests found
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
}
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
<?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
<?php
namespace App\Entity;
<?php declare(strict_types=1);
class Product
{
const FOOD_PRODUCT = 'food';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment