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

Cicd jenkansible #202

Open
wants to merge 73 commits into
base: vp-rem
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
6698dd1
userdata
Sep 30, 2020
bf56ce6
reverted to older branch
imran78688 Sep 30, 2020
fadd760
updating missing deps
imran78688 Sep 30, 2020
ced1ec5
Updated with sonar analysys
imran78688 Sep 30, 2020
73969cf
Testing autobuild trigger in jenkins
imran78688 Sep 30, 2020
ec33ab8
Fixed, Certificate verification failed error.
devopshydclub Oct 5, 2021
fcb0a5e
Jenkins Setup Script updated with new steps
devopshydclub Jan 23, 2022
366ed75
updated path
devopshydclub May 21, 2022
c73e03f
updated whitespaces
devopshydclub May 21, 2022
f75c1e2
whitespaces
devopshydclub May 21, 2022
a2fd246
Fixed variable name
devopshydclub Aug 20, 2022
b13d641
Updated jdk11 version
devopshydclub Sep 10, 2022
320bd50
jacoco version upgrade to 0.8.4
devopshydclub Jan 2, 2023
d55e0d3
Jacoco version change
devopshydclub Jan 2, 2023
402b02b
Update jenkins-setup.sh
devopshydclub May 13, 2023
f690912
Update nexus-setup.sh
devopshydclub Jul 1, 2023
8571179
just modified the jenkins file for testing
Kwasi200 May 15, 2024
1896eae
changed or configured nexus ip (local ip)
Kwasi200 May 15, 2024
077445d
added tools and also testing the webhook
Kwasi200 May 16, 2024
84a9d1c
corrected wrongly spelled maven 3.
Kwasi200 May 16, 2024
7e68ac9
edited enviroment variables and also integrated bu
Kwasi200 May 16, 2024
922c7a8
checked on the spelling of sonerscanner, made corrections
Kwasi200 May 16, 2024
c45acef
ansible code
Kwasi200 May 22, 2024
0b43855
Jenkinsfile, ansible plugin
Kwasi200 May 22, 2024
332fcbe
edited the build stage
Kwasi200 May 23, 2024
1990247
edited out 'nexuspass'
Kwasi200 May 23, 2024
244a4b5
edited nexus repository
Kwasi200 May 23, 2024
376dda8
edited nexus ip
Kwasi200 May 24, 2024
bc2de6e
edited "vprofile-release24" repo
Kwasi200 May 24, 2024
c1aed23
came up with a jenkinsfolder and a jenkinsfile as another option
Kwasi200 May 24, 2024
559c45b
yet another jenkinsfile1 just to test pipeline
Kwasi200 May 24, 2024
61c6395
edited jenkinsfile1 again
Kwasi200 May 24, 2024
9fa679a
edited nexus pass
Kwasi200 May 24, 2024
766480f
edited nexuspass to nexuslogin
Kwasi200 May 24, 2024
450ddcc
edited pom & settings files, changed - to _ for repositories
Kwasi200 May 24, 2024
eeb52d3
just figure the usual mistakes I make with webhook by forgetting the …
Kwasi200 May 24, 2024
0db752b
edited sonarqube on jenkins configuration page
Kwasi200 May 24, 2024
01963fb
switched over to Jenkinsfile1 and updated snapshot repo24
Kwasi200 May 25, 2024
5e64ab2
changed quality gate timeout from 1 hour to 5 mins
Kwasi200 May 25, 2024
eb25888
tinkled with abortpipeline and set it to false
Kwasi200 May 25, 2024
ad9a708
intentionally left out the quality gate stage for a test
Kwasi200 May 25, 2024
0dfd059
edited stage inventory file
Kwasi200 May 25, 2024
6d20101
webhook test !!!
Kwasi200 May 26, 2024
915f815
updated the inventroy to include local ip instead of domain name
Kwasi200 May 26, 2024
c354dee
i had to comment out app01.stg domain name and replace it with local …
Kwasi200 May 26, 2024
95de557
meddled with build_time_stamp to see if the error would clear
Kwasi200 May 26, 2024
409c13e
limited timestamp to only date and no time
Kwasi200 May 26, 2024
0395587
still tempering with the url line in the vpro-app-setup.yml file just…
Kwasi200 May 26, 2024
2322ca5
still playing arpound vpro-app-setup.yml just to clear errors
Kwasi200 May 26, 2024
b2db1c6
still obsessed with the error so I looked this solutionup url = url.…
Kwasi200 May 26, 2024
cc3ef9f
just another try
Kwasi200 May 26, 2024
60b09a5
got rid of colon in timestamp line
Kwasi200 May 26, 2024
cc5bd1e
reverting back code...
Kwasi200 May 26, 2024
45169bd
allow
Kwasi200 May 26, 2024
53e2e8e
testing webhook
Kwasi200 May 27, 2024
0f6f5b0
spaced variables within brackets {{ }}
Kwasi200 May 27, 2024
01641fc
worked on the time variable to correct error ; referenced chatgpt
Kwasi200 May 27, 2024
9ba23d6
on a test mission; let's leave out the time element and see the outcome
Kwasi200 May 27, 2024
f247b23
tweaked the jenkinsfile and got rid of build id which has time stamp
Kwasi200 May 27, 2024
9ee388e
still editing
Kwasi200 May 27, 2024
84ad0c6
just reverting code back to a previous mode ...
Kwasi200 May 27, 2024
518097b
redefined a new time format void of UTC
Kwasi200 May 27, 2024
57baa59
replaced the build-timestamp with the new timestamp
Kwasi200 May 27, 2024
aa83507
did another correction on time
Kwasi200 May 27, 2024
f18c327
another correction with time on setup.yaml file
Kwasi200 May 27, 2024
1ffac46
yet another correction on time !!
Kwasi200 May 27, 2024
3e344f3
changed version to 2
Kwasi200 May 27, 2024
af26757
corrected source and destination of artifacts
Kwasi200 May 27, 2024
b9e51ae
deleted the vprofile version in the url
Kwasi200 May 28, 2024
85d2aef
had to append the .war to the url
Kwasi200 May 28, 2024
9273dec
they seem not to work so reverting code
Kwasi200 May 28, 2024
cc3ae81
changed time from timestamp on vpro-app-setup.yml
Kwasi200 May 28, 2024
1beeadc
taking out slack notification !!
Kwasi200 May 28, 2024
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
62 changes: 49 additions & 13 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
pipeline {

pipeline {

agent any
/*

tools {
maven "maven3"
maven "MAVEN3"
}
*/

environment {
NEXUS_USER = 'admin'
NEXUS_PASS ='1010'
RELEASE_REPO = 'vprofile-release24'
CENTRAL_REPO ='vpro-maven-central-24'
NEXUS_LOGIN = 'nexuslogin'
NEXUSIP ='10.0.12.178'
NEXUSPORT = '8081'
NEXUS_GRP_REPO = 'vpro-maven-group-24'
NEXUS_VERSION = "nexus3"
NEXUS_PROTOCOL = "http"
NEXUS_URL = "172.31.40.209:8081"
NEXUS_REPOSITORY = "vprofile-release"
NEXUS_REPO_ID = "vprofile-release"
NEXUS_URL = "10.0.12.178:8081"
NEXUS_REPOSITORY = "vprofile-release24"
NEXUS_REPOGRP_ID = "vprofile-grp-repo"
NEXUS_CREDENTIAL_ID = "nexuslogin"
ARTVERSION = "${env.BUILD_ID}"
SONARSERVER = "sonarserver"
SONERSCANNER = "sonarscanner"
/* NEXUSPASS = credentials('nexuspass') */
}

stages{

stage('BUILD'){
steps {
sh 'mvn clean install -DskipTests'
/* sh 'mvn clean install -DskipTests' */
sh 'mvn -s settings.xml -DskipTests install'
}
post {
success {
Expand Down Expand Up @@ -56,11 +69,11 @@ pipeline {
stage('CODE ANALYSIS with SONARQUBE') {

environment {
scannerHome = tool 'sonarscanner4'
scannerHome = tool "${SONERSCANNER}"
}

steps {
withSonarQubeEnv('sonar-pro') {
withSonarQubeEnv("${SONARSCANNER}") {
sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \
-Dsonar.projectName=vprofile-repo \
-Dsonar.projectVersion=1.0 \
Expand Down Expand Up @@ -91,7 +104,7 @@ pipeline {
nexusVersion: NEXUS_VERSION,
protocol: NEXUS_PROTOCOL,
nexusUrl: NEXUS_URL,
groupId: pom.groupId,
groupId: NEXUS_REPOGRP_ID,
version: ARTVERSION,
repository: NEXUS_REPOSITORY,
credentialsId: NEXUS_CREDENTIAL_ID,
Expand All @@ -114,8 +127,31 @@ pipeline {
}
}


stage('Ansible Deploy to staging'){
steps {
ansiblePlaybook([
inventory : 'ansible/stage.inventory',
playbook : 'ansible/site.yml',
installation: 'ansible',
colorized : true,
credentialsId: 'applogin',
disableHostKeyChecking: true,
extraVars : [
USER: "admin",
PASS: "${NEXUSPASS}",
nexusip: "10.0.12.178",
reponame: "vprofile-release24",
groupid: "QA",
time: "${env.BUILD_TIMESTAMP}",
build: "${env.BUILD_ID}",
artifactid: "vproapp",
vprofile_version: "vproapp-${env.BUILD_ID}-${env.BUILD_TIMESTAMP}.war"
]
])
}
}

}
}


}
137 changes: 137 additions & 0 deletions Jenkinsfile1
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*def COLOR_MAP = [
'SUCCESS': 'good',
'FAILURE': 'danger',
] */
pipeline {
agent any
tools {
maven "MAVEN3"
/* jdk "OracleJDK8" */
}

environment {
SNAP_REPO = 'vprofile-snapshot-24'
NEXUS_USER = 'admin'
NEXUS_PASS = '1010'
RELEASE_REPO = 'vprofile-release24'
CENTRAL_REPO = 'vpro-maven-central-24'
NEXUSIP = '10.0.12.178'
NEXUSPORT = '8081'
NEXUS_GRP_REPO = 'vpro-maven-group-24'
NEXUS_LOGIN = 'nexuslogin'
SONARSERVER = 'sonarserver'
SONARSCANNER = 'sonarscanner'
NEXUSPASS = credentials('nexuslogin')
}

stages {
stage('Build'){
steps {
sh 'mvn -s settings.xml -DskipTests install'
}
post {
success {
echo "Now Archiving."
archiveArtifacts artifacts: '**/*.war'
}
}
}

stage('Test'){
steps {
sh 'mvn -s settings.xml test'
}

}

stage('Checkstyle Analysis'){
steps {
sh 'mvn -s settings.xml checkstyle:checkstyle'
}
}

stage('Sonar Analysis') {
environment {
scannerHome = tool "${SONARSCANNER}"
}
steps {
withSonarQubeEnv("${SONARSERVER}") {
sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \
-Dsonar.projectName=vprofile \
-Dsonar.projectVersion=1.0 \
-Dsonar.sources=src/ \
-Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \
-Dsonar.junit.reportsPath=target/surefire-reports/ \
-Dsonar.jacoco.reportsPath=target/jacoco.exec \
-Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml'''
}
}
}
/*
stage("Quality Gate") {
steps {
timeout(time: 3, unit: 'MINUTES') {
// Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails
// true = set pipeline to UNSTABLE, false = don't
waitForQualityGate abortPipeline: false
}
}
}
*/
stage("UploadArtifact"){
steps{
nexusArtifactUploader(
nexusVersion: 'nexus3',
protocol: 'http',
nexusUrl: "${NEXUSIP}:${NEXUSPORT}",
groupId: 'QA',
version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}",
repository: "${RELEASE_REPO}",
credentialsId: "${NEXUS_LOGIN}",
artifacts: [
[artifactId: 'vproapp',
classifier: '',
file: 'target/vprofile-v2.war',
type: 'war']
]
)
}
}

stage('Ansible Deploy to staging'){
steps {
ansiblePlaybook([
inventory : 'ansible/stage.inventory',
playbook : 'ansible/site.yml',
installation: 'ansible',
colorized : true,
credentialsId: 'applogin',
disableHostKeyChecking: true,
extraVars : [
USER: "admin",
/*PASS: "${NEXUSPASS}",*/
PASS: "1010",
nexusip: "10.0.12.178",
reponame: "vprofile-release24",
groupid: "QA",
time: "${env.BUILD_TIMESTAMP}",
build: "${env.BUILD_ID}",
artifactid: "vproapp",
vprofile_version: "vproapp-${env.BUILD_ID}-${env.BUILD_TIMESTAMP}.war"
// vprofile_version: "vproapp-${env.BUILD_ID}.war"

]
])
}
}

}
post {
always {
echo 'Slack Notifications.'
slackSend channel: '#jenkinscicd',
color: COLOR_MAP[currentBuild.currentResult],
message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}"
}
}
}
Loading