Skip to content

Commit

Permalink
Update Jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
yash509 authored Jun 15, 2024
1 parent de374dd commit f2c9a65
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pipeline {
cleanWs()
}
}

stage('Unit Tests') {
steps {
sh 'jenkins --version'
Expand All @@ -23,11 +24,13 @@ pipeline {
sh 'docker --version'
}
}

stage('Checkout from Git') {
steps {
git branch: 'main', url: 'https://github.com/yash509/DevSecOps-Uber-Clone-Deployment.git'
}
}

stage('Deployments') {
parallel {
stage('Test deploy to staging') {
Expand All @@ -42,6 +45,7 @@ pipeline {
}
}
}

stage('Test Build') {
steps {
echo 'Building....'
Expand All @@ -52,6 +56,7 @@ pipeline {
}
}
}

stage('Deploy to Staging') {
when {
branch 'main'
Expand All @@ -61,10 +66,11 @@ pipeline {
}
post {
always {
jiraSendDeploymentInfo environmentId: 'us-stg-1', environmentName: 'us-stg-1', environmentType: 'staging'
jiraSendDeploymentInfo environmentId: 'us-stg-1', environmentName: 'us-stg-1', environmentType: 'staging', issueKeys: ['JIRA-1234']
}
}
}

stage('Deploy to Production') {
when {
branch 'main'
Expand All @@ -74,10 +80,11 @@ pipeline {
}
post {
always {
jiraSendDeploymentInfo environmentId: 'us-prod-1', environmentName: 'us-prod-1', environmentType: 'production'
jiraSendDeploymentInfo environmentId: 'us-prod-1', environmentName: 'us-prod-1', environmentType: 'production', issueKeys: ['JIRA-1234']
}
}
}

stage("Sonarqube Analysis ") {
steps {
//dir('Band Website') {
Expand All @@ -88,6 +95,7 @@ pipeline {
}
}
}

stage("quality gate") {
steps {
//dir('Band Website') {
Expand All @@ -97,13 +105,15 @@ pipeline {
}
}
}

stage('Install Dependencies') {
steps {
//dir('Band Website') {
sh "npm install"
//}
}
}

stage('OWASP File System SCAN') {
steps {
//dir('Band Website') {
Expand All @@ -112,13 +122,15 @@ pipeline {
//}
}
}

stage('TRIVY File System SCAN') {
steps {
//dir('Band Website') {
sh "trivy fs . > trivyfs.txt"
//}
}
}

stage('Docker Scout Image Overview') {
steps {
script{
Expand All @@ -128,6 +140,7 @@ pipeline {
}
}
}

stage('Docker Scout CVES File System Scan') {
steps {
script{
Expand All @@ -137,6 +150,7 @@ pipeline {
}
}
}

stage("Docker Image Building"){
steps{
script{
Expand All @@ -149,6 +163,7 @@ pipeline {
}
}
}

stage("Docker Image Tagging"){
steps{
script{
Expand All @@ -160,11 +175,13 @@ pipeline {
}
}
}

stage('Docker Image Scanning') {
steps {
sh "trivy image --format table -o trivy-image-report.html yash5090/uber-application:latest"
}
}

stage("Image Push to DockerHub") {
steps{
script{
Expand All @@ -176,6 +193,7 @@ pipeline {
}
}
}

stage('Docker Scout Image Scanning') {
steps {
script{
Expand All @@ -188,13 +206,15 @@ pipeline {
}
}
}

stage("TRIVY"){
steps{
//dir('Band Website') {
sh "trivy image yash5090/uber-application:latest > trivyimage.txt"
//}
}
}

stage ('Manual Approval'){
steps {
script {
Expand All @@ -220,13 +240,15 @@ pipeline {
}
}
}

stage('Deploy to Docker Container'){
steps{
//dir('BMI Calculator (JS)') {
sh 'docker run -d --name uber-application -p 3000:3000 yash5090/uber-application:latest'
//}
}
}

stage('Deploy to Kubernetes'){
steps{
script{
Expand All @@ -239,6 +261,7 @@ pipeline {
}
}
}

stage('Verify the Kubernetes Deployments') {
steps {
withKubeConfig(caCertificate: '', clusterName: '', contextName: '', credentialsId: 'k8s', namespace: '', restrictKubeConfigAccess: false, serverUrl: '') {
Expand All @@ -255,6 +278,7 @@ pipeline {
}
}
}

post {
always {
script {
Expand Down Expand Up @@ -289,6 +313,7 @@ pipeline {
}
}
}

stage('Result') {
timeout(time: 10, unit: 'MINUTES') {
mail to: '[email protected]',
Expand All @@ -300,3 +325,31 @@ stage('Result') {
parameters: [choice(name: 'action', choices: ['Success'], description: 'Approve deployment')]
}
}

stage('Deploy to Staging') {
when {
branch 'main'
}
steps {
echo 'Deploying to Staging from main....'
}
post {
always {
jiraSendDeploymentInfo environmentId: 'us-stg-1', environmentName: 'us-stg-1', environmentType: 'staging', issueKeys: ['JIRA-1234']
}
}
}

stage('Deploy to Production') {
when {
branch 'main'
}
steps {
echo 'Deploying to Production from main....'
}
post {
always {
jiraSendDeploymentInfo environmentId: 'us-prod-1', environmentName: 'us-prod-1', environmentType: 'production', issueKeys: ['JIRA-1234']
}
}
}

0 comments on commit f2c9a65

Please sign in to comment.