Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #31

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
35 changes: 19 additions & 16 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ pipeline{
choice(name: 'action', choices: 'create\ndelete', description: 'Choose create/Destroy')
string(name: 'ImageName', description: "name of the docker build", defaultValue: 'javapp')
string(name: 'ImageTag', description: "tag of the docker build", defaultValue: 'v1')
string(name: 'DockerHubUser', description: "name of the Application", defaultValue: 'praveensingam1994')
string(name: 'DockerHubUser', description: "name of the Application", defaultValue: 'zeeshanmedlari')
}

tools {
// Specify the Maven tool by name
maven 'Maven-3.9'
}

stages{
Expand All @@ -19,21 +24,21 @@ pipeline{
steps{
gitCheckout(
branch: "main",
url: "https://github.com/praveen1994dec/Java_app_3.0.git"
url: "https://github.com/Zeeshanmedlari/Java_app_3.0.git"
)
}
}

stage('Unit Test maven'){

when { expression { params.action == 'create' } }

steps{
script{

mvnTest()
}
}
}

stage('Integration Test maven'){
when { expression { params.action == 'create' } }
steps{
Expand All @@ -43,26 +48,29 @@ pipeline{
}
}
}

stage('Static code analysis: Sonarqube'){
when { expression { params.action == 'create' } }
steps{
script{

def SonarQubecredentialsId = 'sonarqube-api'
def SonarQubecredentialsId = 'Sonar_token'
statiCodeAnalysis(SonarQubecredentialsId)
}
}
}

stage('Quality Gate Status Check : Sonarqube'){
when { expression { params.action == 'create' } }
steps{
script{

def SonarQubecredentialsId = 'sonarqube-api'
def SonarQubecredentialsId = 'Sonar_token'
QualityGateStatus(SonarQubecredentialsId)
}
}
}

stage('Maven Build : maven'){
when { expression { params.action == 'create' } }
steps{
Expand All @@ -72,6 +80,7 @@ pipeline{
}
}
}

stage('Docker Image Build'){
when { expression { params.action == 'create' } }
steps{
Expand All @@ -81,15 +90,7 @@ pipeline{
}
}
}
stage('Docker Image Scan: trivy '){
when { expression { params.action == 'create' } }
steps{
script{

dockerImageScan("${params.ImageName}","${params.ImageTag}","${params.DockerHubUser}")
}
}
}

stage('Docker Image Push : DockerHub '){
when { expression { params.action == 'create' } }
steps{
Expand All @@ -99,6 +100,7 @@ pipeline{
}
}
}

stage('Docker Image Cleanup : DockerHub '){
when { expression { params.action == 'create' } }
steps{
Expand All @@ -107,6 +109,7 @@ pipeline{
dockerImageCleanup("${params.ImageName}","${params.ImageTag}","${params.DockerHubUser}")
}
}
}
}
}
}

125 changes: 125 additions & 0 deletions Jenkinsfile_tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
@Library('my-shared-library') _

pipeline{

agent any

parameters{

choice(name: 'action', choices: 'create\ndelete', description: 'Choose create/Destroy')
string(name: 'ImageName', description: "name of the docker build", defaultValue: 'javapp')
string(name: 'ImageTag', description: "tag of the docker build", defaultValue: 'v1')
string(name: 'DockerHubUser', description: "name of the Application", defaultValue: 'zeeshanmedlari')
}

tools {
// Specify the Maven tool by name
maven 'Maven-3.9'
}

stages{

stage('Git Checkout'){
when { expression { params.action == 'create' } }
steps{
gitCheckout(
branch: "main",
url: "https://github.com/Zeeshanmedlari/Java_app_3.0.git"
)
}
}

stage('Unit Test maven'){
when { expression { params.action == 'create' } }

steps{
script{
mvnTest()
}
}
}

stage('Integration Test maven'){
when { expression { params.action == 'create' } }
steps{
script{

mvnIntegrationTest()
}
}
}

stage('Static code analysis: Sonarqube'){
when { expression { params.action == 'create' } }
steps{
script{

def SonarQubecredentialsId = 'SonarQube_server'
statiCodeAnalysis(SonarQubecredentialsId)
}
}
}

stage('Quality Gate Status Check : Sonarqube'){
when { expression { params.action == 'create' } }
steps{
script{

def SonarQubecredentialsId = 'Prime_SonarQube'
QualityGateStatus(SonarQubecredentialsId)
}
}
}

stage('Maven Build : maven'){
when { expression { params.action == 'create' } }
steps{
script{

mvnBuild()
}
}
}

stage('Docker Image Build'){
when { expression { params.action == 'create' } }
steps{
script{

dockerBuild("${params.ImageName}","${params.ImageTag}","${params.DockerHubUser}")
}
}
}

stage('Docker Image Scan: trivy '){
when { expression { params.action == 'create' } }
steps{
script{

dockerImageScan("${params.ImageName}","${params.ImageTag}","${params.DockerHubUser}")
}
}
}

stage('Docker Image Push : DockerHub '){
when { expression { params.action == 'create' } }
steps{
script{

dockerImagePush("${params.ImageName}","${params.ImageTag}","${params.DockerHubUser}")
}
}
}

stage('Docker Image Cleanup : DockerHub '){
when { expression { params.action == 'create' } }
steps{
script{

dockerImageCleanup("${params.ImageName}","${params.ImageTag}","${params.DockerHubUser}")
}
}
}
}
}