Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
1f11b52
Create sonar.sh
ecomlisters Jul 29, 2023
49cfab1
Update sonar.sh
ecomlisters Jul 29, 2023
d5ac31a
Create sonar.js
ecomlisters Jul 29, 2023
2f500f0
Update sonar.js
ecomlisters Jul 29, 2023
93c3681
Update package.json
ecomlisters Jul 29, 2023
93b05ca
Delete sonar.js
ecomlisters Jul 29, 2023
ff977c9
Create sonar-project.js
ecomlisters Jul 29, 2023
ad1b855
Update sonar-project.js
ecomlisters Jul 29, 2023
cafe894
Update sonar-project.js
ecomlisters Jul 29, 2023
42b3dcf
Update package.json
ecomlisters Jul 29, 2023
26fea8e
Update sonar-project.js
ecomlisters Jul 29, 2023
d831a46
Added Jenkinsfile
ecomlisters Jul 29, 2023
5883e72
Added Jenkinsfile
ecomlisters Jul 29, 2023
7dec13a
Added Jenkinsfile
ecomlisters Jul 29, 2023
00fcaea
Added Jenkinsfile
ecomlisters Jul 29, 2023
c4333ab
Update README.md
ecomlisters Jul 29, 2023
06d330a
Update Jenkinsfile
ecomlisters Jul 30, 2023
7f3ac4d
Update Jenkinsfile
ecomlisters Jul 30, 2023
8a89fab
Update Jenkinsfile
ecomlisters Jul 30, 2023
16e7178
Update Jenkinsfile
ecomlisters Jul 30, 2023
7a149f6
Update Jenkinsfile
ecomlisters Jul 30, 2023
0213424
Update Jenkinsfile
ecomlisters Jul 30, 2023
a1e53dd
Update index.js
ecomlisters Jul 30, 2023
ca7e81d
Update index.js - testing
ecomlisters Jul 30, 2023
93a94ea
Create Jenkinsfile
ecomlisters Jul 31, 2023
0a689a1
Update Jenkinsfile - pipeline
ecomlisters Jul 31, 2023
55b26ad
Update Jenkinsfile
ecomlisters Jul 31, 2023
d7da8a9
Update Jenkinsfile
ecomlisters Jul 31, 2023
ce7a263
Update Jenkinsfile
ecomlisters Jul 31, 2023
7f161e0
Update Jenkinsfile
ecomlisters Jul 31, 2023
3f078d4
jenkins update
ecomlisters Aug 5, 2023
a8bbbd3
jenkins update
ecomlisters Aug 5, 2023
22bda9e
jenkins update
ecomlisters Aug 5, 2023
7d972b3
jenkins update
ecomlisters Aug 5, 2023
3b89320
jenkins update
ecomlisters Aug 5, 2023
2b0971a
jenkins update
ecomlisters Aug 5, 2023
c442446
sonar
ecomlisters Aug 5, 2023
b2bf027
sonar
ecomlisters Aug 5, 2023
5272c09
sonar
ecomlisters Aug 5, 2023
76cdd94
sonar
ecomlisters Aug 5, 2023
e8c33ac
sonar nodejs
ecomlisters Aug 5, 2023
ecf9277
sonar nodejs
ecomlisters Aug 5, 2023
dae0ece
sonar nodejs
ecomlisters Aug 5, 2023
83cb7ed
sonar nodejs
ecomlisters Aug 5, 2023
26a3723
project update
ecomlisters Aug 5, 2023
c8c7e97
project update
ecomlisters Aug 5, 2023
4a884d0
project update
ecomlisters Aug 5, 2023
ce3d346
project update
ecomlisters Aug 5, 2023
41785f3
project update
ecomlisters Aug 5, 2023
afa3114
project update
ecomlisters Aug 5, 2023
9c926b3
:
ecomlisters Aug 5, 2023
9f75bc2
fixing jenkins file
ecomlisters Aug 5, 2023
1e413b5
fixing jenkins file
ecomlisters Aug 5, 2023
7b46daa
fixing jenkins file 1
ecomlisters Aug 5, 2023
ee59132
env
ecomlisters Aug 5, 2023
693e659
changs in jenkins file
ecomlisters Aug 5, 2023
13019b3
push new changes
ecomlisters Aug 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
node {
def commit_id
stage('Preparation') {
checkout scm
sh "git rev-parse --short HEAD > .git/commit-id"
commit_id = readFile('.git/commit-id').trim()
}
stage('test') {
def myTestContainer = docker.image('node:16')
myTestContainer.pull()
myTestContainer.inside {
sh 'npm install'
}
}
stage('Final'){
echo 'Pipeline complete'
}

}
45 changes: 45 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
pipeline{
agent any

environment {
BRANCH_NAME = "${GIT_BRANCH}"
}

stages {
stage('Install') {
tools {
nodejs 'node16'
}
steps {
sh 'npm install'
}
}
stage('Sonar'){
when {
expression {
BRANCH_NAME == 'main'
}
}
tools {
nodejs 'node16'
}
steps{
script{
echo 'running Sonar stage ...'
}
script {
sonarqubeScannerHome = tool 'sonar'
}
withSonarQubeEnv('sonar') {
sh "${sonarqubeScannerHome}/bin/sonar-scanner -Dsonar.host.url=http://sonarqube:9000 -Dsonar.qualitygate.wait=true"
}
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
}
}

}
}
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//entry point for the app
const express = require("express");
require("dotenv").config();
const app = express();
Expand Down
8 changes: 8 additions & 0 deletions jenkins/sonar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export SONAR_TOKEN=sqp_7c6df26ff26031fa62f4c57849b23896bb7291cc
export SONAR_SCANNER_VERSION=4.7.0.2747
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
echo "sonar variables been set"
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "index.js",
"scripts": {
"start": "node index.js",
"sonar": "node sonar-project.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
Expand All @@ -13,5 +14,8 @@
"dotenv": "^14.1.0",
"ejs": "^3.1.6",
"express": "^4.17.2"
},
"devDependencies": {
"sonarqube-scanner": "^3.0.1"
}
}
7 changes: 7 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sonar.projectKey=nodejs
sonar.projectName=nodejsSample

# we keep tests in magic directories within the main source tree
sonar.exclusions=*.properties
# restrict allowed global variables to only those we use
sonar.javascript.environments=node