From 10fff867f0742ddb863169a677d864836e75009f Mon Sep 17 00:00:00 2001 From: blackcouger <138585163+blackcouger@users.noreply.github.com> Date: Fri, 6 Jun 2025 15:30:46 +0700 Subject: [PATCH 1/6] Create jenkinsfile Signed-off-by: blackcouger <138585163+blackcouger@users.noreply.github.com> --- jenkinsfile | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 jenkinsfile diff --git a/jenkinsfile b/jenkinsfile new file mode 100644 index 00000000..f917f57c --- /dev/null +++ b/jenkinsfile @@ -0,0 +1,77 @@ +pipeline { + agent any + + environment { + DOCKER_HUB = credentials('docker-hub-credentials') + AWS_ACCESS_KEY_ID = credentials('aws-access-key') + AWS_SECRET_ACCESS_KEY = credentials('aws-secret-key') + } + + stages { + stage('Checkout') { + steps { + git branch: 'main', url: 'https://github.com/yourusername/simple-web-app.git' + } + } + + stage('Build') { + steps { + sh 'mvn clean package' // or npm install, gradle build, etc. + } + } + + stage('Unit Tests') { + steps { + sh 'mvn test' // or npm test, pytest, etc. + } + post { + always { + junit '**/target/surefire-reports/*.xml' // path to test results + } + } + } + + stage('Static Code Analysis') { + steps { + withSonarQubeEnv('sonar-server') { + sh 'mvn sonar:sonar' + } + } + } + + stage('Build Docker Image') { + steps { + script { + dockerImage = docker.build("yourusername/web-app:${env.BUILD_ID}") + } + } + } + + stage('Push Docker Image') { + steps { + script { + docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') { + dockerImage.push() + } + } + } + } + + + stage('Integration Tests') { + steps { + sh 'npm run integration-test' // or your integration test command + } + } + + stage('Approval') { + steps { + timeout(time: 1, unit: 'DAYS') { + input message: 'Deploy to production?', ok: 'Deploy' + } + } + } + + } + +} From dec064326d656a665a678de032e5617678f02843 Mon Sep 17 00:00:00 2001 From: blackcouger <138585163+blackcouger@users.noreply.github.com> Date: Fri, 6 Jun 2025 15:32:48 +0700 Subject: [PATCH 2/6] Update jenkinsfile Signed-off-by: blackcouger <138585163+blackcouger@users.noreply.github.com> --- jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jenkinsfile b/jenkinsfile index f917f57c..1ffc6c8c 100644 --- a/jenkinsfile +++ b/jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent any environment { - DOCKER_HUB = credentials('docker-hub-credentials') + DOCKER_HUB = credentials('docker-id') AWS_ACCESS_KEY_ID = credentials('aws-access-key') AWS_SECRET_ACCESS_KEY = credentials('aws-secret-key') } @@ -10,7 +10,7 @@ pipeline { stages { stage('Checkout') { steps { - git branch: 'main', url: 'https://github.com/yourusername/simple-web-app.git' + git branch: 'main', url: 'https://github.com/blackcouger/sample-java-app.git' } } @@ -42,7 +42,7 @@ pipeline { stage('Build Docker Image') { steps { script { - dockerImage = docker.build("yourusername/web-app:${env.BUILD_ID}") + dockerImage = docker.build("docker4241/web-app:${env.BUILD_ID}") } } } @@ -50,7 +50,7 @@ pipeline { stage('Push Docker Image') { steps { script { - docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') { + docker.withRegistry('https://registry.hub.docker.com', 'docker-id') { dockerImage.push() } } From 0dd76436465842a48a739705fcdc4abac25a0a51 Mon Sep 17 00:00:00 2001 From: blackcouger <138585163+blackcouger@users.noreply.github.com> Date: Fri, 6 Jun 2025 15:34:09 +0700 Subject: [PATCH 3/6] Rename jenkinsfile to Jenkinsfile Signed-off-by: blackcouger <138585163+blackcouger@users.noreply.github.com> --- jenkinsfile => Jenkinsfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jenkinsfile => Jenkinsfile (100%) diff --git a/jenkinsfile b/Jenkinsfile similarity index 100% rename from jenkinsfile rename to Jenkinsfile From 7e2bed382b941e4260b5313b6a078d8409e2152b Mon Sep 17 00:00:00 2001 From: blackcouger <138585163+blackcouger@users.noreply.github.com> Date: Fri, 6 Jun 2025 15:34:52 +0700 Subject: [PATCH 4/6] Update Jenkinsfile Signed-off-by: blackcouger <138585163+blackcouger@users.noreply.github.com> --- Jenkinsfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1ffc6c8c..3624e75d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,8 +3,6 @@ pipeline { environment { DOCKER_HUB = credentials('docker-id') - AWS_ACCESS_KEY_ID = credentials('aws-access-key') - AWS_SECRET_ACCESS_KEY = credentials('aws-secret-key') } stages { From 53f98614a2d7848d1a128ec760988331c2a30280 Mon Sep 17 00:00:00 2001 From: blackcouger <138585163+blackcouger@users.noreply.github.com> Date: Fri, 6 Jun 2025 15:40:38 +0700 Subject: [PATCH 5/6] Update Jenkinsfile add maven tool Signed-off-by: blackcouger <138585163+blackcouger@users.noreply.github.com> --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3624e75d..8f2b0668 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,8 @@ pipeline { agent any - + tools { + maven 'maven-391' // Use whatever name you configured +} environment { DOCKER_HUB = credentials('docker-id') } From 6cb02cb867aece12a9e9d44ddad98862f6e88419 Mon Sep 17 00:00:00 2001 From: blackcouger <138585163+blackcouger@users.noreply.github.com> Date: Fri, 6 Jun 2025 15:49:28 +0700 Subject: [PATCH 6/6] Update Jenkinsfile Signed-off-by: blackcouger <138585163+blackcouger@users.noreply.github.com> --- Jenkinsfile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8f2b0668..7096960d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -31,13 +31,6 @@ pipeline { } } - stage('Static Code Analysis') { - steps { - withSonarQubeEnv('sonar-server') { - sh 'mvn sonar:sonar' - } - } - } stage('Build Docker Image') { steps {