From 346235345b41d4cb7a822468daed30f38850582c Mon Sep 17 00:00:00 2001 From: PodssilDev Date: Sun, 2 Apr 2023 15:35:23 -0400 Subject: [PATCH] =?UTF-8?q?[feat]:=20Jenkinsfile=20(Ayudant=C3=ADa=203)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + pep1/Jenkinsfile | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ sonarqube.txt | 2 +- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 pep1/Jenkinsfile diff --git a/.gitignore b/.gitignore index d45a4d5..ff7e880 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +jenkins.war sonarqube-9.9.0.65466 pep1/data/ ## Ignore Visual Studio temporary files, build results, and diff --git a/pep1/Jenkinsfile b/pep1/Jenkinsfile new file mode 100644 index 0000000..b29cdea --- /dev/null +++ b/pep1/Jenkinsfile @@ -0,0 +1,57 @@ +pipeline{ + agent any + tools{ + maven "maven" + } + stages{ + stage("Build JAR File"){ + steps{ + checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/PodssilDev/ayudantias-tingeso-mingeso']]) + dir("pep1"){ + sh "mvn clean install" + } + } + } + stage("Test"){ + steps{ + dir("pep1"){ + sh "mvn test" + } + } + } + stage("SonarQube Analysis"){ + steps{ + dir("pep1"){ + sh "mvn sonar:sonar -Dsonar.projectKey=pep1 -Dsonar.host.url=http://localhost:9000 -Dsonar.login=sqp_fc56b1ba154bd3b0bf2aaa644210b01404548520" + } + } + } + stage("Build Docker Image"){ + steps{ + dir("pep1"){ + sh "docker build -t johnserrano159/proyecto_docker ." + } + } + } + stage("Push Docker Image"){ + steps{ + dir("pep1"){ + withCredentials([string(credentialsId: 'dckrhubpassword', variable: 'dckpass')]){ + sh "docker login -u johnserrano159 -p ${dckpass}" + + } + sh "docker push johnserrano159/proyecto_docker" + + } + + } + } + } + post{ + always{ + dir("pep1"){ + sh "docker logout" + } + } + } +} diff --git a/sonarqube.txt b/sonarqube.txt index bd6fa33..fb15145 100644 --- a/sonarqube.txt +++ b/sonarqube.txt @@ -1 +1 @@ -mvn clean verify sonar:sonar -Dsonar.projectKey=pep1 -Dsonar.host.url=http://localhost:9000 -Dsonar.login=sqp_fc56b1ba154bd3b0bf2aaa644210b01404548520 \ No newline at end of file +mvn sonar:sonar -Dsonar.projectKey=pep1 -Dsonar.host.url=http://localhost:9000 -Dsonar.login=sqp_fc56b1ba154bd3b0bf2aaa644210b01404548520 \ No newline at end of file