Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
79 changes: 79 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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}"
}
}
}
6 changes: 3 additions & 3 deletions _config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ var config = {}

// Update to have your correct username and password
config.mongoURI = {
production: 'mongodb+srv://<USERNAME>:<PASSWORD>@gallery.wc344.mongodb.net/darkroom?retryWrites=true&w=majority',
development: 'mongodb+srv://<USERNAME>:<PASSWORD>@gallery.wc344.mongodb.net/darkroom-dev?retryWrites=true&w=majority',
test: 'mongodb+srv://<USERNAME>:<PASSWORD>@gallery.wc344.mongodb.net/darkroom-test?retryWrites=true&w=majority',
production: 'mongodb+srv://Mwaumba:<password>@gallerycluster.ro7byhq.mongodb.net/?retryWrites=true&w=majority&appName=galleryCluster',
development: 'mongodb+srv://Mwaumba:<password>@gallerycluster.ro7byhq.mongodb.net/?retryWrites=true&w=majority&appName=galleryCluster',
test: 'mongodb+srv://Mwaumba:<password>@gallerycluster.ro7byhq.mongodb.net/?retryWrites=true&w=majority&appName=galleryCluster',
}
module.exports = config;
5 changes: 5 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {};

config.mongoURI = 'mongodb+srv://Mwaumba:<password>@gallerycluster.ro7byhq.mongodb.net/?retryWrites=true&w=majority&appName=galleryCluster';

module.exports = config;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},
"keywords": [],
"author": "",
Expand Down