export MONGO_URI=“mongodb+srv://$MONGO_USERNAME:[email protected]/superData” npm test
— Shell Script
41s
-
export MONGO_URI=mongodb+srv://superuser:****@supercluster.d83jj.mongodb.net/superData
-
npm test
[email protected] test
mocha app-test.js --timeout 10000 --reporter mocha-junit-reporter --exit
(node:39777) [MONGOOSE] DeprecationWarning: Mongoose: the strictQuery
option will be switched back to false
by default in Mongoose 7. Use mongoose.set('strictQuery', false);
if you want to prepare for this change. Or use mongoose.set('strictQuery', true);
to suppress this warning.
(Use node --trace-deprecation ...
to show where the warning was created)
Server successfully running on port - 4000
error!! MongoServerError: bad auth : authentication failed
Ooops, We only have 9 planets and a sun. Select a number from 0 - 9
Ooops, We only have 9 planets and a sun. Select a number from 0 - 9
Ooops, We only have 9 planets and a sun. Select a number from 0 - 9
Ooops, We only have 9 planets and a sun. Select a number from 0 - 9
Ooops, We only have 9 planets and a sun. Select a number from 0 - 9
Ooops, We only have 9 planets and a sun. Select a number from 0 - 9
Ooops, We only have 9 planets and a sun. Select a number from 0 - 9
script returned exit code 8
“I am using correct password and username for the mongoDB, still I am getting errors when I setup my pipeline. Kindly help.”
Below is the Jenkins code:
pipeline {
agent any
tools {
nodejs ‘Nodejs-22.16.0’
}
/environment {
MONGO_URI = “mongodb+srv://supercluster.d83jj.mongodb.net/superData”
}/
stages {
stage(‘Install Dependencies’) {
steps {
sh ‘npm install --no-audit’
}
}
stage(‘Dependency Scanning’) {
parallel {
stage(‘NPM Dependency Audit’) {
steps {
sh ‘’’
npm audit --audit-level=critical
echo $?
‘’’
}
}
stage(‘OWASP Dependency Check’) {
steps {
dependencyCheck additionalArguments: ‘’’
–scan './'
–out './'
–format 'ALL'
–prettyPrint’‘’, odcInstallation: ‘OWASP-DepCheck-12.10’
dependencyCheckPublisher failedTotalCritical: 2, failedTotalHigh: 2, pattern: 'dependency-check-report.xml', skipNoReportFiles: true, stopBuild: true, unstableTotalCritical: 1, unstableTotalHigh: 3
junit allowEmptyResults: true, keepProperties: true, testResults: 'dependency-check-junit.xml'
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, icon: '', keepAll: true, reportDir: './',
reportFiles: 'dependency-check-jenkins.html', reportName: 'Dependency-Check HTML Report', reportTitles: '', useWrapperFileDirectly: true])
}
}
}
}
stage('Unit Testing') {
steps {
withCredentials([usernamePassword(credentialsId: 'mongo-db-creds', passwordVariable: 'MONGO_PASSWORD', usernameVariable: 'MONGO_USERNAME')]) {
sh'''
export MONGO_URI="mongodb+srv://$MONGO_USERNAME:[email protected]/superData"
npm test
'''
}
junit allowEmptyResults: true, keepProperties: true, testResults: 'test-results.xml'
}
}
}
}