Skip to content

Commit

Permalink
Create Jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
prashantsuk authored Mar 15, 2024
1 parent 24ebc88 commit 631137a
Showing 1 changed file with 120 additions and 0 deletions.
120 changes: 120 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@

pipeline{
agent any
tools{
jdk 'jdk17'
nodejs 'node19'
}
environment {
SCANNER_HOME=tool 'sonar-scanner'
}
stages {
stage('clean workspace'){
steps{
cleanWs()
}
}
stage('Checkout from Git'){
steps{
git branch: 'main', url: 'https://github.com/prashantsuk/Myntra-Clone.git'
}
}
stage("Sonarqube Analysis "){
steps{
withSonarQubeEnv('sonar-server') {
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=myntra \
-Dsonar.projectKey=myntra'''
}
}
}
stage("quality gate"){
steps {
script {
waitForQualityGate abortPipeline: false, credentialsId: 'Sonar-token'
}
}
}
stage('Install Dependencies') {
steps {
sh "npm install"
}
}
stage('OWASP FS SCAN') {
steps {
//dependencyCheck additionalArguments: '--scan ./ --disableYarnAudit --disableNodeAudit', odcInstallation: 'DP-Check'
// dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
sh 'pwd'
}
}
stage('Docker Scout FS') {
steps {
script{
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){
//sh 'docker-scout quickview fs://.'
//sh 'docker-scout cves fs://.'
sh 'docker --version'
}
}
}
}
stage("Docker Build & Push"){
steps{
script{
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){
sh "docker build -t myntra ."
sh "docker tag myntra prashant680844/myntra:latest "
sh "docker push prashant680844/myntra:latest"
}
}
}
}
stage('Docker Scout Image') {
steps {
script{
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){
sh 'docker-scout quickview prashant680844/myntra:latest'
sh 'docker-scout cves prashant680844/myntra:latest'
sh 'docker-scout recommendations prashant680844/myntra:latest'
}
}
}
}
stage('TRIVY FS SCAN') {
steps {
script{
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){
// sh 'docker-scout quickview prashant680844/myntra:latest'
//sh 'docker-scout cves prashant680844/myntra:latest'
//sh 'docker-scout recommendations prashant680844/myntra:latest'

sh 'trivy image prashant680844/myntra:latest > trivyfs.json'
}
}

}
}
stage("Remove container"){
steps{
sh "docker stop myntra | true"
sh "docker rm myntra | true"
}
}
stage("deploy_docker"){
steps{
sh "docker run -d --name myntra -p 3000:3000 prashant680844/myntra:latest"
}
}
stage('Deploy to kubernets'){
steps{
script{
dir('K8S') {
withKubeConfig(caCertificate: '', clusterName: '', contextName: '', credentialsId: 'k8s', namespace: '', restrictKubeConfigAccess: false, serverUrl: '') {
sh 'kubectl apply -f deployment.yml'
sh 'kubectl apply -f service.yml'
}
}
}
}
}
}
}

0 comments on commit 631137a

Please sign in to comment.