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

[upd] update files

parent 878b05c3
No related branches found
No related tags found
No related merge requests found
......@@ -11,22 +11,23 @@ pipeline {
agent any
steps {
echo "Phase 1 : checkout"
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 'e8eaded1-e9c8-4185-b828-0b89af4d1024', url: 'https://gitlab.imt-atlantique.fr/f21munie/project_jenkins_php.git']]]) }
checkout scmGit(branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://gitlab.imt-atlantique.fr/f21munie/project_jenkins_php.git']])
}
}
stage('tests') {
parallel {
stage('hadolint') {
// Phase : agent Dockerfile im age hadolint
// Phase 2 : agent Dockerfile image hadolint
agent {
docker {
image 'docker.io/hadolint/hadolint:v2.12.0-alpine'
}
}
steps {
echo 'Phase : création hadolint.json'
echo 'Phase 3 : création hadolint.json'
sh 'touch hadolin.json'
echo 'Phase : exécution hadolint sur les deux Dockerfile du'
echo 'Phase 4 : exécution hadolint sur les deux Dockerfiles'
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'
......@@ -34,7 +35,7 @@ pipeline {
}
stage('tests statiques') {
// "Phase 2 : agent Dockerfile"
// "Phase 5 : agent Dockerfile intégration"
agent {
dockerfile {
dir 'build/docker/phpunit'
......@@ -42,13 +43,13 @@ pipeline {
}
}
steps {
echo "Phase 3 : préparation de l'environnement"
echo "Phase 6 : 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"
echo "Phase 7: Réalisation des tests statiques"
sh 'make tests_statiques'
echo "Phase 8: 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')]
}
}
......@@ -61,15 +62,15 @@ pipeline {
}
}
steps {
echo "Phase 6 : préparation de l'environnement"
echo "Phase 9 : préparation de l'environnement"
sh 'ls -l'
sh 'make test'
sh 'make clean'
sh 'ls -l'
echo "Phase 7: Réalisation des tests unitaires"
sh 'make qa'
echo "Phase 8 : publication du résultat des tests junit"
echo "Phase 10 : Réalisation des tests unitaires"
sh 'make tests_unitaires'
echo "Phase 11 : 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"
echo "Phase 12 : 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],
......@@ -82,14 +83,21 @@ pipeline {
stage('deploy') {
agent any
steps {
echo "Phase : Script de construction l'image numérotée"
echo "Phase : Script de publication de l'imagesur le registre privé"
echo "Phase 13 : Script de construction l'image numérotée"
echo "Phase 14 : Script de publication de l'imagesur le registre privé"
script {
docker.withRegistry('gitlab-registry.imt-atlantique.fr/f21munie/project_jenkins_php') {
docker.withRegistry('http://localhost:5000') {
docker.build("checktva:${env.BUILD_ID}", "./src").push()
}
}
}
}
}
post {
always {
echo "Phase 15 : Nettoyer l'espace de travail"
cleanWs()
}
}
}
\ No newline at end of file
......@@ -10,9 +10,9 @@ clean:
@mkdir -p build/logs
@mkdir -p build/coverage
test:
tests_unitaires:
@phpunit
qa:
tests_statiques:
@phpcs src/ --standard=psr2 --report=checkstyle --report-file=$(LOG_CS) || exit 0
@phpmd src/ xml cleancode,codesize,design,naming,unusedcode --reportfile $(LOG_MD) || exit 0
\ No newline at end of file
......@@ -10,6 +10,8 @@ RUN wget -q https://phar.phpunit.de/phpunit-9.phar -O phpunit \
&& wget -q https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar -O phpcs \
&& wget -q https://phpmd.org/static/latest/phpmd.phar -O phpmd
FROM php:8.0-cli
COPY --from=downloader /tmp/php* /usr/local/bin/
......
version: '3.3'
version: '3.8'
volumes:
jenkins:
driver: local
driver: local
registry:
driver: local
services:
jenkins:
image: docker.io/jenkins/jenkins:2.361.4-lts
......@@ -13,4 +17,27 @@ services:
volumes:
- jenkins:/var/jenkins_home:Z
- /var/run/docker.sock:/var/run/docker.sock:Z
- /usr/bin/docker:/usr/bin/docker:Z
\ No newline at end of file
- /usr/bin/docker:/usr/bin/docker:Z
registry:
image: docker.io/registry:2.8.1
container_name: registry
ports:
- 5000:5000
volumes:
- registry:/var/lib/registry:Z
environment:
- REGISTRY_STORAGE_DELETE_ENABLED=true
ui:
image: docker.io/joxit/docker-registry-ui:2.2.0
container_name: ui
ports:
- 8082:80
environment:
- SINGLE_REGISTRY=true
- REGISTRY_TITLE=Registre DOCKER
- NGINX_PROXY_PASS_URL=http://registry:5000
- DELETE_IMAGES=true
depends_on:
- registry
\ No newline at end of file
FROM php:8.0-cli
COPY code.php /app/code.php
COPY tva.php /app/tva.php
COPY checktva.php /app/checktva.php
......
<?php
require "code.php";
#use App\Entity;
require "tva.php";
if (! isset($argv[3])) {
exit("Usage: php ".basename(__FILE__)." <NAME> <TYPE> <PRICE>\n");
......@@ -8,8 +7,7 @@ if (! isset($argv[3])) {
try {
$product = new Product($argv[1], $argv[2], $argv[3]);
$product->computeTVA();
#\Product::computeTVA($argv[1], $argv[2], $argv[3]);
echo " OK TVA calculated\n";
} catch (\Exception | TypeError $e) {
} catch (Exception | TypeError $e) {
echo " KO TVA not calculated ", $e->getMessage(),"\n";
}
\ No newline at end of file
<?php declare(strict_types=1);
#namespace App\Entity;
class Product
{
const FOOD_PRODUCT = 'food';
......
File moved
<?php
require_once 'src/code.php';
\ No newline at end of file
require_once 'src/tva.php';
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment