
That One Friday Deployment We’ll Never Forget
It was a typical Friday afternoon, and everything seemed calm. We had a small change to push to production—just a minor update, nothing major. Confident that it wouldn’t cause issues, we deployed it right before the weekend.
Big mistake.
Minutes after the deployment, alerts started firing. The production environment was acting up, and customers were complaining. The team scrambled to roll back, but since it was Friday, some key engineers were already offline. What should have been a smooth weekend turned into a nightmare of debugging and damage control.
That was the day we learned our lesson: No more Friday deployments.
To make sure it never happens again, we set up an automated rule in Jenkins that blocks deployments on Fridays and even sends a warning message to our Telegram chat. Here’s how you can do the same.
Prerequisites
Before we begin, ensure you have:
- A Jenkins pipeline set up with a deployment stage.
- The Telegram Notification Plugin configured with your bot token.
- A branch-based deployment strategy, where production deployments occur from the
main
branch.
The Solution: Jenkins Pipeline Script
The pipeline will:
- Check the current day.
- If it’s Friday, send a Telegram message and abort the deployment.
- Otherwise, prompt for manual approval before proceeding with deployment.
Here’s the Jenkinsfile implementing this logic:
pipeline {
agent any
stages {
stage('Approval') {
when {
branch 'main'
}
steps {
script {
def dayOfWeek = sh(script: "date +%A", returnStdout: true).trim()
if (dayOfWeek == "Friday") {
def errorMessage = "🚫 *${env.JOB_NAME}* #${env.BUILD_NUMBER} - Sorry, it's *Friday*: \nDeployments to production are not allowed."
telegramSend errorMessage
currentBuild.result = 'ABORTED'
error(errorMessage)
}
telegramSend "⌛️ *${env.JOB_NAME}* #${env.BUILD_NUMBER} - *Deploy to PROD?*\n${env.BUILD_URL}"
input id: 'Deploy',
message: 'Deploy to production?',
submitter: 'admin'
}
}
}
}
}
Explanation of the Script
1. Checking the Current Day
def dayOfWeek = sh(script: "date +%A", returnStdout: true).trim()
This shell command extracts the current day (e.g., “Monday”, “Tuesday”, etc.) and trims any extra spaces.
2. Handling Friday Deployments
if (dayOfWeek == "Friday") {
def errorMessage = "🚫 *${env.JOB_NAME}* #${env.BUILD_NUMBER} - Sorry, it's *Friday*: \nDeployments to production are not allowed."
telegramSend errorMessage
currentBuild.result = 'ABORTED'
error(errorMessage)
}
- If the day is Friday, the pipeline:
- Sends a Telegram message notifying the team about the restriction.
- Marks the build as
ABORTED
to prevent further execution. - Stops execution with
error(errorMessage)
.


3. Manual Approval for Other Days
telegramSend "⌛️ *${env.JOB_NAME}* #${env.BUILD_NUMBER} - *Deploy to PROD?*\n${env.BUILD_URL}"
input id: 'Deploy',
message: 'Deploy to production?',
submitter: 'admin'
- If it’s not Friday, the script:
- Notifies the team on Telegram that deployment approval is required.
- Waits for manual input approval from designated users before proceeding.
By integrating Jenkins, Telegram notifications, and a day-based check, we successfully enforce a “No Friday Deployments” policy. This simple automation helps prevent potential weekend deployment disasters while keeping teams informed in real time.