From 5dbe0c87486ba9998fde24332625897ac99d9f99 Mon Sep 17 00:00:00 2001 From: samuel Date: Tue, 24 May 2022 11:05:50 +0000 Subject: [PATCH 01/13] config --- jenkinsfile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 jenkinsfile diff --git a/jenkinsfile b/jenkinsfile new file mode 100644 index 00000000..79d207a1 --- /dev/null +++ b/jenkinsfile @@ -0,0 +1,30 @@ +pipeline { + agent any + + stages { + + stage("Initial cleanup") { + steps { + dir("${WORKSPACE}") { + deleteDir() + } + } + } + + stage('Checkout SCM') { + steps { + git branch: 'main', url: 'https://github.com/darey-devops/php-todo.git' + } + } + + stage('Prepare Dependencies') { + steps { + sh 'mv .env.sample .env' + sh 'composer install' + sh 'php artisan migrate' + sh 'php artisan db:seed' + sh 'php artisan key:generate' + } + } + } +} \ No newline at end of file From 920c15f895f85fe6e41e7c5ec72eff90c4870a87 Mon Sep 17 00:00:00 2001 From: samuel Date: Tue, 24 May 2022 15:20:21 +0000 Subject: [PATCH 02/13] github link added --- jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkinsfile b/jenkinsfile index 79d207a1..5b717a52 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -13,7 +13,7 @@ pipeline { stage('Checkout SCM') { steps { - git branch: 'main', url: 'https://github.com/darey-devops/php-todo.git' + git branch: 'main', url: 'https://github.com/Revival-fire/php-todo.git' } } From 01e307be6f75df119de89538e625729017985cf0 Mon Sep 17 00:00:00 2001 From: samuel Date: Wed, 25 May 2022 09:43:11 +0000 Subject: [PATCH 03/13] corrections --- .env.sample | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.env.sample b/.env.sample index 1c39502a..4fb1621e 100644 --- a/.env.sample +++ b/.env.sample @@ -3,10 +3,12 @@ APP_DEBUG=true APP_KEY=SomeRandomString APP_URL=http://localhost -DB_HOST=127.0.0.1 +DB_HOST=0.0.0.0 DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=sePret^i +DB_CONNECTION=mysql +DB_PORT=3306 CACHE_DRIVER=file SESSION_DRIVER=file From af0efa8959d0057fbda5b3fe2cc3cc10f337c8db Mon Sep 17 00:00:00 2001 From: samuel Date: Wed, 25 May 2022 11:58:27 +0000 Subject: [PATCH 04/13] mysql credentials --- .env.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.sample b/.env.sample index 4fb1621e..0363df15 100644 --- a/.env.sample +++ b/.env.sample @@ -3,7 +3,7 @@ APP_DEBUG=true APP_KEY=SomeRandomString APP_URL=http://localhost -DB_HOST=0.0.0.0 +DB_HOST=172.31.22.135 DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=sePret^i From 7da5c31a9feee6e168e7948816e38d5fcfc70a99 Mon Sep 17 00:00:00 2001 From: samuel Date: Wed, 25 May 2022 13:23:27 +0000 Subject: [PATCH 05/13] corrections --- jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jenkinsfile b/jenkinsfile index 5b717a52..80851185 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -26,5 +26,11 @@ pipeline { sh 'php artisan key:generate' } } + + stage('Execute Unit Tests') { + steps { + sh './vendor/bin/phpunit' + } + } } } \ No newline at end of file From 572657bbf4f783ca8537812b582cdc0ff56dbe19 Mon Sep 17 00:00:00 2001 From: samuel Date: Wed, 25 May 2022 13:38:42 +0000 Subject: [PATCH 06/13] additions to jenkinsfile --- jenkinsfile | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/jenkinsfile b/jenkinsfile index 80851185..2674b063 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -31,6 +31,30 @@ pipeline { steps { sh './vendor/bin/phpunit' } - } + } + + stage('Code Analysis') { + steps { + sh 'phploc app/ --log-csv build/logs/phploc.csv' + } + } + stage('Plot Code Coverage Report') { + steps { + + plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Lines of Code (LOC),Comment Lines of Code (CLOC),Non-Comment Lines of Code (NCLOC),Logical Lines of Code (LLOC) ', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'A - Lines of code', yaxis: 'Lines of Code' + plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Directories,Files,Namespaces', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'B - Structures Containers', yaxis: 'Count' + plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Average Class Length (LLOC),Average Method Length (LLOC),Average Function Length (LLOC)', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'C - Average Length', yaxis: 'Average Lines of Code' + plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Cyclomatic Complexity / Lines of Code,Cyclomatic Complexity / Number of Methods ', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'D - Relative Cyclomatic Complexity', yaxis: 'Cyclomatic Complexity by Structure' + plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Classes,Abstract Classes,Concrete Classes', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'E - Types of Classes', yaxis: 'Count' + plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Methods,Non-Static Methods,Static Methods,Public Methods,Non-Public Methods', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'F - Types of Methods', yaxis: 'Count' + plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Constants,Global Constants,Class Constants', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'G - Types of Constants', yaxis: 'Count' + plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Test Classes,Test Methods', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'I - Testing', yaxis: 'Count' + plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Logical Lines of Code (LLOC),Classes Length (LLOC),Functions Length (LLOC),LLOC outside functions or classes ', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'AB - Code Structure by Logical Lines of Code', yaxis: 'Logical Lines of Code' + plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Functions,Named Functions,Anonymous Functions', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'H - Types of Functions', yaxis: 'Count' + plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Interfaces,Traits,Classes,Methods,Functions,Constants', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'BB - Structure Objects', yaxis: 'Count' + + } + } + } } \ No newline at end of file From e5dd953fb36af41e82649566ac78e3c6fb1c3aae Mon Sep 17 00:00:00 2001 From: samuel Date: Wed, 25 May 2022 14:46:18 +0000 Subject: [PATCH 07/13] additions to jenkinsfile --- jenkinsfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/jenkinsfile b/jenkinsfile index 2674b063..7b233ddb 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -56,5 +56,32 @@ pipeline { } } + stage ('Package Artifact') { + steps { + sh 'zip -qr php-todo.zip ${WORKSPACE}/*' + } + } + + stage ('Upload Artifact to Artifactory') { + steps { + script { + def server = Artifactory.server 'artifactory-server' + def uploadSpec = """{ + "files": [ + { + "pattern": "php-todo.zip", + "target": "/php-todo", + "props": "type=zip;status=ready" + + } + ] + }""" + + server.upload spec: uploadSpec + } + } + + } + } } \ No newline at end of file From fb9ca394626803f0cbeea76ec94109c954ab49d4 Mon Sep 17 00:00:00 2001 From: samuel Date: Tue, 31 May 2022 08:05:00 +0000 Subject: [PATCH 08/13] additions to jenkinsfile --- jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkinsfile b/jenkinsfile index 7b233ddb..931eb353 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -70,7 +70,7 @@ pipeline { "files": [ { "pattern": "php-todo.zip", - "target": "/php-todo", + "target": "agbokpo/php-todo", "props": "type=zip;status=ready" } From 1fc8190e1a4f56bbf0442a935c00ddaf623a2635 Mon Sep 17 00:00:00 2001 From: samuel Date: Wed, 1 Jun 2022 18:17:11 +0000 Subject: [PATCH 09/13] corrections --- jenkinsfile => Jenkinsfile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) rename jenkinsfile => Jenkinsfile (96%) diff --git a/jenkinsfile b/Jenkinsfile similarity index 96% rename from jenkinsfile rename to Jenkinsfile index 931eb353..0688b650 100644 --- a/jenkinsfile +++ b/Jenkinsfile @@ -57,9 +57,9 @@ pipeline { } stage ('Package Artifact') { - steps { + steps { sh 'zip -qr php-todo.zip ${WORKSPACE}/*' - } + } } stage ('Upload Artifact to Artifactory') { @@ -83,5 +83,11 @@ pipeline { } + stage ('Deploy to Dev Environment') { + steps { + build job: 'Ansible-config-mgt/main', parameters: [[$class: 'StringParameterValue', name: 'env', value: 'dev']], propagate: false, wait: true + } + } + } } \ No newline at end of file From 4c93ec8c82c9f17b1262729bc388045a3ab38433 Mon Sep 17 00:00:00 2001 From: samuel Date: Sat, 4 Jun 2022 05:16:24 +0000 Subject: [PATCH 10/13] add sonar --- Jenkinsfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 0688b650..ca0a4675 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,6 +55,18 @@ pipeline { } } + stage('SonarQube Quality Gate') { + environment { + scannerHome = tool 'SonarQubeScanner' + } + steps { + withSonarQubeEnv('sonarqube') { + sh "${scannerHome}/bin/sonar-scanner" + } + + } + } + stage ('Package Artifact') { steps { From f948da57edcec2a0977ad5136bf826c656add8a1 Mon Sep 17 00:00:00 2001 From: samuel Date: Sat, 4 Jun 2022 05:21:00 +0000 Subject: [PATCH 11/13] add sonar --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index ca0a4675..0079c48e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,6 +55,7 @@ pipeline { } } + stage('SonarQube Quality Gate') { environment { scannerHome = tool 'SonarQubeScanner' From 8538bd83be3427fbb9925da836633f4071ec9863 Mon Sep 17 00:00:00 2001 From: samuel Date: Sat, 4 Jun 2022 06:13:54 +0000 Subject: [PATCH 12/13] add sonar --- Jenkinsfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0079c48e..77cef258 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,16 +55,19 @@ pipeline { } } - + stage('SonarQube Quality Gate') { + when { branch pattern: "^develop*|^hotfix*|^release*|^main*", comparator: "REGEXP"} environment { scannerHome = tool 'SonarQubeScanner' } steps { withSonarQubeEnv('sonarqube') { - sh "${scannerHome}/bin/sonar-scanner" + sh "${scannerHome}/bin/sonar-scanner -Dproject.settings=sonar-project.properties" + } + timeout(time: 1, unit: 'MINUTES') { + waitForQualityGate abortPipeline: true } - } } From 05127d8d2c7103380b01eff5dcb6d5c33c3862c1 Mon Sep 17 00:00:00 2001 From: samuel Date: Mon, 6 Jun 2022 14:25:26 +0000 Subject: [PATCH 13/13] changes --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 77cef258..2e1a516a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -41,7 +41,7 @@ pipeline { stage('Plot Code Coverage Report') { steps { - plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Lines of Code (LOC),Comment Lines of Code (CLOC),Non-Comment Lines of Code (NCLOC),Logical Lines of Code (LLOC) ', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'A - Lines of code', yaxis: 'Lines of Code' + plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Lines of Code (LOC),Comment Lines of Code (CLOC),Non-Comment Lines of Code (NCLOC),Logical Lines of Code (LLOC)', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'A - Lines of code', yaxis: 'Lines of Code' plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Directories,Files,Namespaces', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'B - Structures Containers', yaxis: 'Count' plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Average Class Length (LLOC),Average Method Length (LLOC),Average Function Length (LLOC)', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'C - Average Length', yaxis: 'Average Lines of Code' plot csvFileName: 'plot-396c4a6b-b573-41e5-85d8-73613b2ffffb.csv', csvSeries: [[displayTableFlag: false, exclusionValues: 'Cyclomatic Complexity / Lines of Code,Cyclomatic Complexity / Number of Methods ', file: 'build/logs/phploc.csv', inclusionFlag: 'INCLUDE_BY_STRING', url: '']], group: 'phploc', numBuilds: '100', style: 'line', title: 'D - Relative Cyclomatic Complexity', yaxis: 'Cyclomatic Complexity by Structure'