Skip to content
Open

Qa #5

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
f6bd445
Update pom.xml
venkatd901 Aug 11, 2022
ec087b0
Update pom.xml
venkatd901 Aug 11, 2022
362e5e0
Update pom.xml
venkatd901 Aug 11, 2022
5578adf
Update pom.xml
venkatd901 Aug 11, 2022
012196b
Create template.yaml
venkatd901 Aug 30, 2022
10db74c
Update Jenkinsfile
venkatd901 Aug 30, 2022
94acd5d
Create pipeline_config.groovy
venkatd901 Aug 30, 2022
7a4b1db
Update pipeline_config.groovy
venkatd901 Aug 30, 2022
d98b946
Update Jenkinsfile
venkatd901 Aug 30, 2022
4986c06
Update Jenkinsfile
venkatd901 Aug 30, 2022
3174e5d
Update pipeline_config.groovy
venkatd901 Aug 30, 2022
df9a7fb
Update Jenkinsfile
venkatd901 Aug 30, 2022
b27e56c
Update Jenkinsfile
venkatd901 Aug 30, 2022
cfe9e4b
Update Jenkinsfile
venkatd901 Aug 30, 2022
1d4e17f
Update Jenkinsfile
venkatd901 Aug 30, 2022
3a1e643
Update Jenkinsfile
venkatd901 Aug 30, 2022
7452d83
Create config.groovy
venkatd901 Aug 30, 2022
12b2765
Create params.yaml
venkatd901 Aug 30, 2022
939cc80
Update Jenkinsfile
venkatd901 Aug 30, 2022
1c29085
Update Jenkinsfile
venkatd901 Aug 30, 2022
d61c2ed
Update Jenkinsfile
venkatd901 Aug 30, 2022
d90f6f5
Create dockerBuild.groovy
venkatd901 Aug 30, 2022
a72b8e4
Update Jenkinsfile
venkatd901 Aug 30, 2022
969bb44
Update Jenkinsfile
venkatd901 Aug 30, 2022
715f51c
Update Jenkinsfile
venkatd901 Aug 30, 2022
df676f4
Update Jenkinsfile
venkatd901 Aug 30, 2022
c3392cf
Update config.groovy
venkatd901 Aug 30, 2022
a126ba2
Update Jenkinsfile
venkatd901 Aug 30, 2022
142e960
Update Jenkinsfile
venkatd901 Aug 30, 2022
887cd81
Update Jenkinsfile
venkatd901 Aug 30, 2022
b8fd867
Update pipeline_config.groovy
venkatd901 Aug 30, 2022
c252ce7
Update Jenkinsfile
venkatd901 Aug 31, 2022
0ff1d80
Update Jenkinsfile
venkatd901 Sep 7, 2022
4b3b67b
Update Jenkinsfile
venkatd901 Sep 7, 2022
ee9b569
Update Jenkinsfile
venkatd901 Sep 7, 2022
c7f10b9
Update Jenkinsfile
venkatd901 Sep 7, 2022
65d84fc
Update Jenkinsfile
venkatd901 Sep 7, 2022
b0d8ab1
Update pipeline_config.groovy
venkatd901 Sep 8, 2022
dab6dcd
Update Jenkinsfile
venkatd901 Sep 8, 2022
eba0476
Update pipeline_config.groovy
venkatd901 Sep 8, 2022
99e671e
Update Jenkinsfile
venkatd901 Sep 8, 2022
b06f67e
Update pipeline_config.groovy
venkatd901 Sep 8, 2022
b85db36
Update Jenkinsfile
venkatd901 Sep 8, 2022
215db04
Update pipeline_config.groovy
venkatd901 Sep 8, 2022
edd254a
Update Jenkinsfile
venkatd901 Sep 8, 2022
cbfdbd6
Update Jenkinsfile
venkatd901 Sep 8, 2022
ccc8459
Update pipeline_config.groovy
venkatd901 Sep 8, 2022
66a6c13
Update pipeline_config.groovy
venkatd901 Sep 8, 2022
be7111b
Update Jenkinsfile
venkatd901 Sep 12, 2022
546b061
Update Jenkinsfile
venkatd901 Sep 14, 2022
6e31f9b
Update pipeline_config.groovy
venkatd901 Sep 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,43 @@
def gv

pipeline{
agent any

stages{
stage('SCM Checkout') {
steps {
git branch: '${params.branch_name}',
credentialsId: '${params.git_creds}',
url: '${params.git_url}'
}
}
stage("Sonarqube analysis"){
steps{
script{
withSonarQubeEnv(credentialsId: 'new_sonar') {
sh 'mvn sonar:sonar'
script {
gv = load "pipeline_config.groovy"
echo "sonarQube code quality check"
gv.qualityanalysis()
}
}
}
stage("Build jar") {
steps {
script {
echo "building jar"
gv.buildJar()
}
}
}
stage("Roll Back"){
steps {
script {
echo "roll back to previous version"
gv.rollback()
}
}
}
}
post{
post{
always{
echo "========always========"
}
Expand All @@ -22,4 +48,6 @@ pipeline{
echo "========pipeline execution failed========"
}
}


}
42 changes: 42 additions & 0 deletions pipeline_config.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
def buildJar() {
echo "building the application..."
sh 'mvn package'
}

def qualityanalysis() {
echo "sonarQube code quality check"
withSonarQubeEnv(credentialsId: 'mysorarqube', installationName: 'sample_java') {
sh 'mvn sonar:sonar'
}
}

def testReport(){
echo 'Generated Test report...'
sh 'mvn test'
}


def rollback() {
echo "roll back to previous version"
if (currentBuild?.getPreviousBuild()?.result == 'FAILURE') {
if (currentBuild.resultIsBetterOrEqualTo(
currentBuild.getPreviousBuild().result)) {
echo 'build has been fixed'
}
}
}

def buildImage() {
echo "building the docker image..."
withCredentials([usernamePassword(credentialsId: 'ACR', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
sh 'docker build -t maven--java/demo-app:jma-2.0 .'
sh "echo $PASS | docker login -u $USER --password-stdin"
sh 'docker push maven--java/demo-app:jma-2.0'
}
}

def deployApp() {
echo 'deploying the application...'
}

return this
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
<distributionManagement>
<snapshotRepository>
<id>nexusdeploymentrepo</id>
<url>http://34.122.147.224:8081/repository/maven-snapshots/</url>
<url>http://52.140.6.198:8081/repository/maven-snapshots/</url>
</snapshotRepository>
<repository>
<id>nexusdeploymentrepo</id>
<url>http://34.122.147.224:8081/repository/maven-releases/</url>
<url>http://52.140.6.198:8081/repository/advisingbank-release/</url>
</repository>

</distributionManagement>
Expand Down
62 changes: 62 additions & 0 deletions template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
version: 1

name: Container Build
description: "This will create a multibranch pipeline job for container builds"

type: pipeline-template
templateType: MULTIBRANCH

parameters:
- name: github_organization
type: string
displayName: Specify the GitHub Organisation e.g. lot2learn (mandatory)

- name: github_repo
type: string
displayName: Specify the GitHub Repository e.g. nodejs-project (mandatory)

- name: headWildcardFilterIncludes
type: string
displayName: "Space-separated list of name patterns to consider. You may use * as a wildcard; for example: master release*"

- name: headWildcardFilterExcludes
type: string
displayName: "Space-separated list of name patterns to ignore even if matched by the includes list. For example: release alpha-* beta-*"

- name: github_creds
type: credentials
displayName: Specify the GitHub Credentials ID name for the source code repository (mandatory)

- name: dockerfiles
type: string
displayName: Specify the path to the Dockerfile(s) as semicolon delimited string e.g. app01/Dockerfile (optional)

- name: build_arguments
type: string
displayName: Specify the container build arguments as semicolon delimited string e.g. VAR1=FOO;VAR2=BAR (optional)

- name: docker_tag
type: string
displayName: Specify the container tagname e.g. arnabdnany1706/smartdb:latest (mandatory)

multibranch:
branchSource:
github:
repoOwner: ${github_organization}
repository: ${github_repo}
credentialsId: ${github_creds}
traits:
- gitHubBranchDiscovery:
strategyId: 3
- headWildcardFilter:
includes: ${headWildcardFilterIncludes}
excludes: ${headWildcardFilterExcludes}

strategy:
$class: DefaultBranchPropertyStrategy # All branches get the same properties
props:
- $class: NoTriggerBranchProperty # Suppress automatic SCM triggering

orphanedItemStrategy:
daysToKeep: 60
scanRepositoryInterval: 15 minutes
23 changes: 23 additions & 0 deletions vars/config.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def buildJar() {
echo "building the application..."
sh 'mvn package'
}

def rollback() {
echo "roll back to previous version"
hudson.model.Result.SUCCESS.equals(currentBuild.rawBuild.getPreviousBuild()?.getResult()) == true
}
def buildImage() {
echo "building the docker image..."
withCredentials([usernamePassword(credentialsId: 'ACR', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
sh 'docker build -t maven--java/demo-app:jma-2.0 .'
sh "echo $PASS | docker login -u $USER --password-stdin"
sh 'docker push maven--java/demo-app:jma-2.0'
}
}

def deployApp() {
echo 'deploying the application...'
}

return this
19 changes: 19 additions & 0 deletions vars/dockerBuild.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def login() {
withCredentials([usernamePassword(credentialsId: '******', usernameVariable: '*****', passwordVariable: '*****')]) {
sh """
docker login --username="${hubUsername}" --password="${hubPassword}"
"""
}
}

def build(String tag) {
sh """
docker build -t "${tag}" .
"""
}

def push(String tag) {
sh """
docker push "${tag}"
"""
}
62 changes: 62 additions & 0 deletions vars/params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
version: 1

name: Container Build
description: "This will create a multibranch pipeline job for container builds"

type: pipeline-template
templateType: MULTIBRANCH

parameters:
- name: github_organization
type: string
displayName: Specify the GitHub Organisation e.g. lot2learn (mandatory)

- name: github_repo
type: string
displayName: Specify the GitHub Repository e.g. nodejs-project (mandatory)

- name: headWildcardFilterIncludes
type: string
displayName: "Space-separated list of name patterns to consider. You may use * as a wildcard; for example: master release*"

- name: headWildcardFilterExcludes
type: string
displayName: "Space-separated list of name patterns to ignore even if matched by the includes list. For example: release alpha-* beta-*"

- name: github_creds
type: credentials
displayName: Specify the GitHub Credentials ID name for the source code repository (mandatory)

- name: dockerfiles
type: string
displayName: Specify the path to the Dockerfile(s) as semicolon delimited string e.g. app01/Dockerfile (optional)

- name: build_arguments
type: string
displayName: Specify the container build arguments as semicolon delimited string e.g. VAR1=FOO;VAR2=BAR (optional)

- name: docker_tag
type: string
displayName: Specify the container tagname e.g. arnabdnany1706/smartdb:latest (mandatory)

multibranch:
branchSource:
github:
repoOwner: ${github_organization}
repository: ${github_repo}
credentialsId: ${github_creds}
traits:
- gitHubBranchDiscovery:
strategyId: 3
- headWildcardFilter:
includes: ${headWildcardFilterIncludes}
excludes: ${headWildcardFilterExcludes}

strategy:
$class: DefaultBranchPropertyStrategy # All branches get the same properties
props:
- $class: NoTriggerBranchProperty # Suppress automatic SCM triggering

orphanedItemStrategy:
daysToKeep: 60
scanRepositoryInterval: 15 minutes