forked from riyapulusuganti/Demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JenkinsSonar
71 lines (60 loc) · 2.91 KB
/
JenkinsSonar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def artifactname = "devops-snow-build-app.jar"
def repoName = "JenkinsDevOpsProject"
def pipelineName = "SunilPipelines/Sunil-Scripted-Pipeline-Sonar"
def semanticVersion = "${env.BUILD_NUMBER}.0.0"
def packageName = "devops-snow-build-pkg_${env.BUILD_NUMBER}"
def version = "${env.BUILD_NUMBER}.0"
def pkgName = "devops-snow-build-pkg_${env.BUILD_NUMBER}"
def changeRequestId = "testId"
def artifactVersion = "1.${env.BUILD_NUMBER}"
def artifactSemVersion = "${artifactVersion}.0"
pipeline {
agent any
tools {
maven 'Maven'
}
environment {
SCANNER_HOME = tool 'sonarScanner'
}
stages {
stage('Build &1') {
steps {
sh 'mvn -B -DskipTests clean compile'
snDevOpsArtifact(artifactsPayload: """{"artifacts": [{"name": "${artifactname}", "version": "1.${env.BUILD_NUMBER}","semanticVersion": "1.${env.BUILD_NUMBER}.0","repositoryName": "${repoName}"}],"branchName":"master"}""")
snDevOpsPackage(name: "${pkgName}-${env.BUILD_NUMBER}", artifactsPayload: """{"artifacts":[{"name": "${artifactname}", "version": "1.${env.BUILD_NUMBER}", "repositoryName": "${repoName}"}], "branchName":"master"}""")
}
}
stage('Test @2') {
steps {
snDevOpsStep()
sh 'mvn test'
}
post {
always {
junit "**/target/surefire-reports/*.xml"
}
}
}
stage('Deploy1@!') {
steps {
echo 'Deploying the ....'
snDevOpsSecurityResult securityResultAttributes: "{'scanner': 'Veracode','applicationName': 'PetStoreAPI-Github', 'securityToolId' : '5d8cbe8ec38a31108a432e0ad001315e'}" //'securityToolId' : '05bf3d33c32f2110cd4cf92f0501311b'}"
// sonarSummaries()
sleep 10
}
}
stage('prod deploy') {
steps {
echo "packageName - ${packageName}"
//snDevOpsSecurityResult securityResultAttributes: "{'scanner': 'Veracode','applicationName': 'PetStoreAPI-Github', 'securityToolId' : 'b866c7429398311065edfca86cba104c'}" //'securityToolId' : '05bf3d33c32f2110cd4cf92f0501311b'}"
snDevOpsChange changeRequestDetails: '{ "attributes": {"chg_model": "adffaa9e4370211072b7f6be5bb8f2ed"}}'
}
}
}
}
def sonarSummaries(){
withSonarQubeEnv('sonarQube_local'){
sh '${SCANNER_HOME}/bin/sonar-scanner -Dsonar.projectKey=balu-sn-devops_First_repo -Dsonar.organization=First_repo -Dsonar.host.url=http://34.229.47.174/ -Dsonar.login=3dc9eb4459800df74ddf2421ec6a3ed986af3090 -Dsonar.java.binaries=target/'
// sh '${SCANNER_HOME}/bin/sonar-scanner -Dsonar.projectKey=Basic_Project1_DevOps-Test_AYsd6a1P_xDA_af4Ff8Y -Dsonar.organization=DevOps-Test -Dsonar.host.url=http://sonarqube2.sndevops.xyz/ -Dsonar.login=squ_033057218193341f5dfb9483758aaaa866c968c7 -Dsonar.java.binaries=target/'
}
}