diff --git a/.env.sample b/.env.sample index 1c39502a5..413125b66 100644 --- a/.env.sample +++ b/.env.sample @@ -3,7 +3,7 @@ APP_DEBUG=true APP_KEY=SomeRandomString APP_URL=http://localhost -DB_HOST=127.0.0.1 +DB_HOST=172.31.28.198 DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=sePret^i diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..873ae49b4 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,107 @@ +pipeline { + agent any + + stages { + + stage("Initial cleanup") { + steps { + dir("${WORKSPACE}") { + deleteDir() + } + } + } + + stage('Checkout SCM') { + steps { + git branch: 'main', url: 'https://github.com/zidon4real/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' + } + } + + stage('Execute Unit Tests') { + 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' + + } + } + + 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" + } + timeout(time: 1, unit: 'MINUTES') { + waitForQualityGate abortPipeline: true + } + } + } + + 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 + } + } + } + stage ('Deploy to Dev Environment') { + steps { + build job: 'ansible-config/main', parameters: [[$class: 'StringParameterValue', name: 'env', value: 'dev']], propagate: false, wait: true + } + } + +} +} \ No newline at end of file diff --git a/README.md b/README.md index 65e8b628b..774968398 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,6 @@ php artisan serve [Complete Tutorial](https://laravel.com/docs/5.2/quickstart) + +This Project has a folder named "img" where steps have been screenshot. + diff --git a/img/artifactory login page.png b/img/artifactory login page.png new file mode 100644 index 000000000..13aa13c6c Binary files /dev/null and b/img/artifactory login page.png differ diff --git a/img/deployed artifacts.png b/img/deployed artifacts.png new file mode 100644 index 000000000..a5b3a2af1 Binary files /dev/null and b/img/deployed artifacts.png differ diff --git a/img/jfro.png b/img/jfro.png new file mode 100644 index 000000000..b70446590 Binary files /dev/null and b/img/jfro.png differ diff --git a/img/oceanblue plugin echo building stage.png b/img/oceanblue plugin echo building stage.png new file mode 100644 index 000000000..14efeb611 Binary files /dev/null and b/img/oceanblue plugin echo building stage.png differ diff --git a/img/php dependencies installation.png b/img/php dependencies installation.png new file mode 100644 index 000000000..148f65434 Binary files /dev/null and b/img/php dependencies installation.png differ diff --git a/img/phploc plot.png b/img/phploc plot.png new file mode 100644 index 000000000..746138e25 Binary files /dev/null and b/img/phploc plot.png differ diff --git a/img/ran asnible playbook.png b/img/ran asnible playbook.png new file mode 100644 index 000000000..a58ba73d3 Binary files /dev/null and b/img/ran asnible playbook.png differ diff --git a/img/sonarqube dashboard.png b/img/sonarqube dashboard.png new file mode 100644 index 000000000..4f5d2274c Binary files /dev/null and b/img/sonarqube dashboard.png differ diff --git a/img/sonarqube gate.png b/img/sonarqube gate.png new file mode 100644 index 000000000..d5ce97798 Binary files /dev/null and b/img/sonarqube gate.png differ diff --git a/img/sonarqube landing page.png b/img/sonarqube landing page.png new file mode 100644 index 000000000..26fbf015c Binary files /dev/null and b/img/sonarqube landing page.png differ diff --git a/img/stages assignment.png b/img/stages assignment.png new file mode 100644 index 000000000..15bbb4d50 Binary files /dev/null and b/img/stages assignment.png differ diff --git a/img/successful db installation.png b/img/successful db installation.png new file mode 100644 index 000000000..0b226c123 Binary files /dev/null and b/img/successful db installation.png differ diff --git a/phploc.phar b/phploc.phar new file mode 100644 index 000000000..bfa1e2d8f Binary files /dev/null and b/phploc.phar differ