diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..7cd7ce5 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,82 @@ +pipeline { + agent any + + tools { + jdk "java-8" + maven "maven-3" + } + stages { + stage ('clone'){ + steps { + git "https://github.com/komalkhiratkar/VProfile.git" + } + } + stage ('test'){ + steps { + echo " running test cases" + } + } + stage ('build') { + steps { + sh 'mvn package' + } + } + stage('CODE ANALYSIS with SONARQUBE') { + + environment { + scannerHome = tool 'sonarqube-4' + } + + steps { + withSonarQubeEnv('sonarqube') { + sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ + -Dsonar.projectName=vprofile-repo \ + -Dsonar.projectVersion=1.0 \ + -Dsonar.sources=src/ \ + -Dsonar.login=admin \ + -Dsonar.password=admin1234 \ + -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''' + } + + //timeout(time: 1, unit: 'MINUTES') { + // waitForQualityGate abortPipeline: false + // } + } + } + + + stage('Nexus artifact'){ + steps { + + nexusArtifactUploader( + nexusVersion: 'nexus3', + protocol: 'http', + nexusUrl: '172.31.8.147:8081', + groupId: 'DEV', + version: '$BUILD_NUMBER', + repository: 'Vprofile-repo', + credentialsId: 'nexus-creds', + artifacts: [ + [artifactId: 'vprofile', + classifier: '', + file: 'target/vprofile-v1.war', + type: 'war'] + ] + ) + + } + } + + stage('deploy to tomcat'){ + steps{ + + deploy adapters: [tomcat8(credentialsId: 'tomcat-creds', path: '', url: 'http://172.31.3.167:8080')], contextPath: 'january-9', war: 'target/vprofile-v1.war' + + } + } + } +} + diff --git a/Jenkinsfile-3 b/Jenkinsfile-3 new file mode 100644 index 0000000..073d052 --- /dev/null +++ b/Jenkinsfile-3 @@ -0,0 +1,61 @@ +pipeline { + environment { + registry = "komal921/docker-test" + registryCredential = 'docc-credentials' + dockerImage = '' + } + agent any + tools { + jdk "java-8" + maven "maven-3" + } + stages { + stage('Cloning Git') { + steps { + git branch: 'komal', changelog: false, credentialsId: 'docc-credentials', poll: false, url: 'https://github.com/komalkhiratkar/VProfile.git' + } + } + + stage ('Build maven') { + steps { + sh 'mvn package' + } + } + + stage('Building image') { + steps{ + script { + dockerImage = docker.build registry + ":$BUILD_NUMBER" + } + } + } + + stage('Deploy Image') { + steps{ + script { + docker.withRegistry( '', registryCredential ) { + dockerImage.push() + } + } + } + } + stage('Remove Unused docker image') { + steps{ + sh "docker rmi $registry:$BUILD_NUMBER" + } + } + stage ('install docker and pull image') { + steps{ + script { + withDockerRegistry(credentialsId: 'docc-credentials') { + sh "sudo -S apt install docker.io -y" + sh "docker pull komal921/docker-test ." + sh "docker run -itd komal921/docker-test" + } + } + } + } + } + } + + diff --git a/sample-playbook.yml b/sample-playbook.yml new file mode 100644 index 0000000..ef7d8d9 --- /dev/null +++ b/sample-playbook.yml @@ -0,0 +1,8 @@ +--- + - hosts: ubuntu + become: yes + tasks: + - name: install tree package + apt: + name: tree + state: present