diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..622635c31 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,79 @@ +pipeline { + agent any + + environment { + MONGO_URI = 'mongodb+srv://Mwaumba:Pilot2005@gallerycluster.ro7byhq.mongodb.net/?retryWrites=true&w=majority&appName=galleryCluster' + EMAIL_RECIPIENT = 'mmwafuga@gmail.com' + SLACK_WEBHOOK = credentials('https://hooks.slack.com/services/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') + } + + stages { + stage('Clone Repository') { + steps { + // Clone the repository + git url: 'https://github.com/Mwaumba/gallery.git', branch: 'main' + } + } + + stage('Notify Slack') { + steps { + slackSend(channel: '#ip', message: "Pipeline notification", token: slack-webhook) + } + } + + stage('Install Dependencies') { + steps { + sh 'npm install' + } + } + + stage('Build') { + steps { + // Any build steps + sh 'npm run build' + } + } + + stage('Test') { + steps { + // Run tests + sh 'npm test' + } + post { + success { + echo 'Tests passed successfully!' + } + failure { + echo 'Tests failed! Sending email notification...' + emailext body: "Tests failed on Jenkins for branch: ${env.BRANCH_NAME}", + recipientProviders: [culprits(), requestor()], + subject: "Failed: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", + to: "${EMAIL_RECIPIENT}" + } + } + } + + stage('Deploy to Render') { + steps { + sh ''' + curl -X POST "https://api.render.com/deploy/srv-cq1g5vd6l47c73anfc8g" \ + -H "Authorization: Bearer rnd_DHsliOtd5D0LKY7Cl7wiO2WppLq8" \ + -d '' + ''' + } + } + } + + post { + success { + echo 'Pipeline completed successfully!' + } + failure { + echo 'Tests failed! Sending email notification...' + emailext body: "Tests failed on Jenkins for branch: ${env.BRANCH_NAME}", + recipientProviders: [culprits(), requestor()], + subject: "Failed: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", + to: "${EMAIL_RECIPIENT}" + } + } +} diff --git a/_config.js b/_config.js index 23720eb7c..20f84cb39 100644 --- a/_config.js +++ b/_config.js @@ -2,8 +2,8 @@ var config = {} // Update to have your correct username and password config.mongoURI = { - production: 'mongodb+srv://:@gallery.wc344.mongodb.net/darkroom?retryWrites=true&w=majority', - development: 'mongodb+srv://:@gallery.wc344.mongodb.net/darkroom-dev?retryWrites=true&w=majority', - test: 'mongodb+srv://:@gallery.wc344.mongodb.net/darkroom-test?retryWrites=true&w=majority', + production: 'mongodb+srv://Mwaumba:@gallerycluster.ro7byhq.mongodb.net/?retryWrites=true&w=majority&appName=galleryCluster', + development: 'mongodb+srv://Mwaumba:@gallerycluster.ro7byhq.mongodb.net/?retryWrites=true&w=majority&appName=galleryCluster', + test: 'mongodb+srv://Mwaumba:@gallerycluster.ro7byhq.mongodb.net/?retryWrites=true&w=majority&appName=galleryCluster', } module.exports = config; diff --git a/config.js b/config.js new file mode 100644 index 000000000..db4e2e600 --- /dev/null +++ b/config.js @@ -0,0 +1,5 @@ +const config = {}; + +config.mongoURI = 'mongodb+srv://Mwaumba:@gallerycluster.ro7byhq.mongodb.net/?retryWrites=true&w=majority&appName=galleryCluster'; + +module.exports = config; diff --git a/package.json b/package.json index 82097f703..bd57bea99 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "server.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "jest" }, "keywords": [], "author": "",