From b4c8c876b65f180bb48658ac2002f0c783b2373e Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Mon, 2 Jan 2023 18:35:13 +0000 Subject: [PATCH 01/16] Update --- Jenkinsfile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..48a74223e --- /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/Brian0213/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 41689c53a1da95909b17a73c0d6345235da63cf8 Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Mon, 2 Jan 2023 19:15:12 +0000 Subject: [PATCH 02/16] Update php --- artisan | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/artisan b/artisan index df630d0d6..275ca3f3e 100644 --- a/artisan +++ b/artisan @@ -48,4 +48,4 @@ $status = $kernel->handle( $kernel->terminate($input, $status); -exit($status); +exit($status); \ No newline at end of file From d1de1ce14269cfe30c6b603dc5b803a9cca17f62 Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Mon, 2 Jan 2023 20:56:40 +0000 Subject: [PATCH 03/16] Update DB --- .env.sample | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.env.sample b/.env.sample index 1c39502a5..63d4034a9 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=172.31.44.235 DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=sePret^i +DB_CONNECTION=mysql +DB_PORT=3306 CACHE_DRIVER=file SESSION_DRIVER=file From 9bc6ad96694a6b030fc2c12183d777b1e69fddce Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Mon, 2 Jan 2023 21:04:25 +0000 Subject: [PATCH 04/16] update --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 48a74223e..8a8c4bce0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,5 +26,10 @@ pipeline { sh 'php artisan key:generate' } } + + stage('Execute Unit Tests') { + steps { + sh './vendor/bin/phpunit' + } } } \ No newline at end of file From bed3236eff17b7a3e0150ea1f85b1e78eca3787d Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Mon, 2 Jan 2023 21:06:05 +0000 Subject: [PATCH 05/16] update --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 8a8c4bce0..0430e3f60 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,4 +32,5 @@ pipeline { sh './vendor/bin/phpunit' } } +} } \ No newline at end of file From 82ffc7d1e2ad1a6715470762669c66fa40b51288 Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Mon, 2 Jan 2023 21:18:39 +0000 Subject: [PATCH 06/16] Adding tasks to php jenkinsfile --- Jenkinsfile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 0430e3f60..c59629162 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,5 +32,30 @@ pipeline { 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 b02caab0e3f19790dce03494c8c058da950ea36d Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Mon, 2 Jan 2023 21:53:10 +0000 Subject: [PATCH 07/16] Adding tasks --- Jenkinsfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index c59629162..fe4c7c53b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -57,5 +57,32 @@ stage('Plot Code Coverage Report') { } } + +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": "PBL/php-todo", + "props": "type=zip;status=ready" + + } + ] + }""" + + server.upload spec: uploadSpec + } + } + + } } } \ No newline at end of file From 7ddf5e4451dab3919e82e5cd8a6ddfb1a1b22a35 Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Mon, 2 Jan 2023 22:11:18 +0000 Subject: [PATCH 08/16] Adding Deployment file --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index fe4c7c53b..628d5299b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -84,5 +84,11 @@ stage ('Upload Artifact to Artifactory') { } } + +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 92f38f4ee56dd6060a4842057b55b18579e2ddfc Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Mon, 2 Jan 2023 22:40:20 +0000 Subject: [PATCH 09/16] Update --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 628d5299b..57c9b23bf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -91,4 +91,4 @@ stage ('Deploy to Dev Environment') { } } } -} \ No newline at end of file +}, \ No newline at end of file From c340a8c691ea9ae6e2b2cd276e3aeb1a12178c58 Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Mon, 2 Jan 2023 22:42:32 +0000 Subject: [PATCH 10/16] Adding --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 57c9b23bf..628d5299b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -91,4 +91,4 @@ stage ('Deploy to Dev Environment') { } } } -}, \ No newline at end of file +} \ No newline at end of file From f9704a851c56ced1f310e56ce5f15a3bd0477d24 Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Thu, 5 Jan 2023 14:06:17 +0000 Subject: [PATCH 11/16] Update Jenkinsfile --- Jenkinsfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 628d5299b..a8925ce7e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -57,6 +57,19 @@ stage('Plot Code Coverage Report') { } } + +stage('SonarQube Quality Gate') { + environment { + scannerHome = tool 'SonarQubeScanner' + } + steps { + withSonarQubeEnv('sonarqube') { + sh "${scannerHome}/bin/sonar-scanner" + } + + } + } + stage ('Package Artifact') { steps { From 4f6849afca65b3b514cb3e0f7f014e3f1eaa6e58 Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Thu, 5 Jan 2023 14:50:31 +0000 Subject: [PATCH 12/16] Update --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a8925ce7e..5e50abbc9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -60,11 +60,11 @@ stage('Plot Code Coverage Report') { stage('SonarQube Quality Gate') { environment { - scannerHome = tool 'SonarQubeScanner' + scannerHome = tool 'sonar' } steps { - withSonarQubeEnv('sonarqube') { - sh "${scannerHome}/bin/sonar-scanner" + withSonarQubeEnv() { + sh "${scannerHome}/bin/sonar-scanner --version" } } From a2185e6323603c0ec7fe3edfe279006975ebecb8 Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Thu, 5 Jan 2023 14:57:55 +0000 Subject: [PATCH 13/16] Update --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5e50abbc9..f86c3c74f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -60,11 +60,11 @@ stage('Plot Code Coverage Report') { stage('SonarQube Quality Gate') { environment { - scannerHome = tool 'sonar' + scannerHome = tool 'SonarQubeScanner' } steps { - withSonarQubeEnv() { - sh "${scannerHome}/bin/sonar-scanner --version" + withSonarQubeEnv('sonarqube') { + sh "${scannerHome}/bin/sonar-scanner" } } From 595ece4a65f6887788d9b12af3cf7f290403db07 Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Thu, 5 Jan 2023 15:57:59 +0000 Subject: [PATCH 14/16] Update --- Jenkinsfile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f86c3c74f..64e0420e6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -59,17 +59,19 @@ stage('Plot Code Coverage Report') { } stage('SonarQube Quality Gate') { + when { branch pattern: "^develop*|^hotfix*|^release*|^main*", comparator: "REGEXP"} environment { - scannerHome = tool 'SonarQubeScanner' - } + scannerHome = tool 'SonarQubeScanner' + } steps { - withSonarQubeEnv('sonarqube') { - sh "${scannerHome}/bin/sonar-scanner" - } - + withSonarQubeEnv('sonarqube') { + sh "${scannerHome}/bin/sonar-scanner -Dproject.settings=sonar-project.properties" + } + timeout(time: 1, unit: 'MINUTES') { + waitForQualityGate abortPipeline: true } } - +} stage ('Package Artifact') { steps { From f45f85420e8f964f263e747663289e76fc1c9994 Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Thu, 5 Jan 2023 16:27:03 +0000 Subject: [PATCH 15/16] Update --- Jenkinsfile | 17 +++++++---------- sonar.properties | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 64e0420e6..3f4916496 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -59,19 +59,16 @@ stage('Plot Code Coverage Report') { } 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 -Dproject.settings=sonar-project.properties" + environment { + scannerHome = tool 'SonarQubeScanner' } - timeout(time: 1, unit: 'MINUTES') { - waitForQualityGate abortPipeline: true + steps { + withSonarQubeEnv('sonarqube') { + sh "${scannerHome}/bin/sonar-scanner" + } + } } -} stage ('Package Artifact') { steps { diff --git a/sonar.properties b/sonar.properties index 38159e49d..943bb0c2b 100644 --- a/sonar.properties +++ b/sonar.properties @@ -1,4 +1,4 @@ -sonar.host.url=http://18.192.57.119:9000 +sonar.host.url=http://3.17.166.34:9000 sonar.projectKey=php-todo #----- Default source code encoding sonar.sourceEncoding=UTF-8 From 4aeb1b6965a57a5161068cc9f5659ff359c08d9d Mon Sep 17 00:00:00 2001 From: Brian0213 Date: Thu, 5 Jan 2023 18:00:50 +0000 Subject: [PATCH 16/16] Update Php Jenkinsfile --- Jenkinsfile | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3f4916496..64e0420e6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -59,16 +59,19 @@ stage('Plot Code Coverage Report') { } stage('SonarQube Quality Gate') { - environment { - scannerHome = tool 'SonarQubeScanner' + when { branch pattern: "^develop*|^hotfix*|^release*|^main*", comparator: "REGEXP"} + environment { + scannerHome = tool 'SonarQubeScanner' + } + steps { + withSonarQubeEnv('sonarqube') { + sh "${scannerHome}/bin/sonar-scanner -Dproject.settings=sonar-project.properties" } - steps { - withSonarQubeEnv('sonarqube') { - sh "${scannerHome}/bin/sonar-scanner" - } - + timeout(time: 1, unit: 'MINUTES') { + waitForQualityGate abortPipeline: true } } +} stage ('Package Artifact') { steps {