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

New pull request #115

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
67375ac
just change to trigger jenkins
IbrahimMohamedi Oct 14, 2023
749a7bb
Update README.md
IbrahimMohamedi Oct 15, 2023
005cc04
multi-branch
IbrahimMohamedi Oct 15, 2023
da8f062
Jenkins files
IbrahimMohamedi Oct 15, 2023
d5eff7c
Jenkins files updated to conditional stage for master
IbrahimMohamedi Oct 15, 2023
42fed74
updated worker pom
IbrahimMohamedi Oct 15, 2023
ce68a67
Update Jenkinsfile
IbrahimMohamedi Oct 15, 2023
dd82202
Merge pull request #1 from IbrahimMohamedi/IbrahimMohamedi-patch-1
IbrahimMohamedi Oct 15, 2023
9001a83
just a change
IbrahimMohamedi Oct 15, 2023
d77fc5f
java pipleine for worker app
IbrahimMohamedi Oct 15, 2023
143fb7e
Update Jenkinsfile
IbrahimMohamedi Oct 15, 2023
10608cb
Update Jenkinsfile
IbrahimMohamedi Oct 15, 2023
4fe6fbf
Update Jenkinsfile
IbrahimMohamedi Oct 15, 2023
0db7ef2
Update Jenkinsfile
IbrahimMohamedi Oct 15, 2023
94d62da
Update Jenkinsfile
IbrahimMohamedi Oct 15, 2023
d688fe4
Update Jenkinsfile
IbrahimMohamedi Oct 15, 2023
a6519bb
Dockerfile added
IbrahimMohamedi Oct 15, 2023
0d73abe
Merge branch 'feature/workerpipe' of https://github.com/IbrahimMohame…
IbrahimMohamedi Oct 15, 2023
55d7e9a
Update Jenkinsfile
IbrahimMohamedi Oct 16, 2023
c8c286c
Update Jenkinsfile
IbrahimMohamedi Oct 16, 2023
6282e1b
Merge pull request #2 from IbrahimMohamedi/feature/workerpipe
IbrahimEltigani Oct 16, 2023
97f68ff
Update Jenkinsfile
IbrahimMohamedi Oct 16, 2023
2a9837d
Merge pull request #3 from IbrahimMohamedi/feature/workerpipe
IbrahimEltigani Oct 16, 2023
eb78db3
Update Jenkinsfile
IbrahimMohamedi Oct 16, 2023
827ee73
Merge pull request #4 from IbrahimMohamedi/feature/workerpipe
IbrahimEltigani Oct 16, 2023
0bc4d72
adding docker compose
IbrahimMohamedi Oct 16, 2023
779ac16
Added Jenkinsfile for all microservices toghether whith dev deploy us…
IbrahimMohamedi Oct 17, 2023
f29714a
Merge pull request #5 from IbrahimMohamedi/feature/monppipe
IbrahimEltigani Oct 17, 2023
e113cc4
Update Jenkinsfile
IbrahimMohamedi Oct 17, 2023
c7e9c7d
Merge pull request #6 from IbrahimMohamedi/feature/monppipe
IbrahimEltigani Oct 17, 2023
5bbde8a
Update Jenkinsfile
IbrahimMohamedi Oct 17, 2023
8de31f6
Update sonar-project.properties
IbrahimMohamedi Oct 17, 2023
8bd5583
Merge pull request #7 from IbrahimMohamedi/IbrahimMohamedi-patch-3
IbrahimEltigani Oct 17, 2023
9026ffd
Merge pull request #8 from IbrahimMohamedi/IbrahimMohamedi-patch-2
IbrahimEltigani Oct 17, 2023
25e5908
Update sonar-project.properties
IbrahimMohamedi Oct 17, 2023
608c685
Merge pull request #9 from IbrahimMohamedi/IbrahimMohamedi-patch-4
IbrahimEltigani Oct 17, 2023
adbfd56
Update sonar-project.properties
IbrahimMohamedi Oct 17, 2023
7553543
Merge pull request #10 from IbrahimMohamedi/IbrahimMohamedi-patch-5
IbrahimEltigani Oct 17, 2023
92284a9
Update app.py
IbrahimMohamedi Nov 4, 2023
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
271 changes: 271 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
pipeline {

agent none

stages {

stage('worker-build') {
agent {
docker {
image 'maven:3.8.5-jdk-11-slim'
args '-v $HOME/.m2:/root/.m2'
}

}
when {
changeset '**/worker/**'
}
steps {
echo 'Compiling worker app..'
dir(path: 'worker') {
sh 'mvn compile'
}

}
}

stage('worker test') {
agent {
docker {
image 'maven:3.8.5-jdk-11-slim'
args '-v $HOME/.m2:/root/.m2'
}

}
when {
changeset '**/worker/**'
}
steps {
echo 'Running Unit Tets on worker app.'
dir(path: 'worker') {
sh 'mvn clean test'
}

}
}

stage('worker-package') {
agent {
docker {
image 'maven:3.8.5-jdk-11-slim'
args '-v $HOME/.m2:/root/.m2'
}

}
when {
branch 'master'
changeset '**/worker/**'
}
steps {
echo 'Packaging worker app'
dir(path: 'worker') {
sh 'mvn package -DskipTests'
archiveArtifacts(artifacts: '**/target/*.jar', fingerprint: true)
}

}
}

stage('worker-docker-package') {
agent any
when {
changeset '**/worker/**'
branch 'master'
}
steps {
echo 'Packaging worker app with docker'
script {
docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') {
def workerImage = docker.build("ibrahimmohamedi/worker:v${env.BUILD_ID}", './worker')
workerImage.push()
workerImage.push("${env.BRANCH_NAME}")
workerImage.push('latest')
}
}

}
}

stage('result-build') {
agent {
docker {
image 'node:8.16.0-alpine'
}

}
when {
changeset '**/result/**'
}
steps {
echo 'Compiling result app..'
dir(path: 'result') {
sh 'npm install'
}

}
}

stage('result-test') {
agent {
docker {
image 'node:8.16.0-alpine'
}

}
when {
changeset '**/result/**'
}
steps {
echo 'Running Unit Tests on result app..'
dir(path: 'result') {
sh 'npm install'
sh 'npm test'
}

}
}

stage('result-docker-package') {
agent any
when {
changeset '**/result/**'
branch 'master'
}
steps {
echo 'Packaging result app with docker'
script {
docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') {
def resultImage = docker.build("ibrahimmohamedi/result:v${env.BUILD_ID}", './result')
resultImage.push()
resultImage.push("${env.BRANCH_NAME}")
resultImage.push('latest')
}
}
}
}

stage('vote-build') {
agent {
docker {
image 'python:2.7.16-slim'
args '--user root'
}

}
when {
changeset '**/vote/**'
}
steps {
echo 'Compiling vote app.'
dir(path: 'vote') {
sh 'pip install -r requirements.txt'
}

}
}

stage('vote-test') {
agent {
docker {
image 'python:2.7.16-slim'
args '--user root'
}

}
when {
changeset '**/vote/**'
}
steps {
echo 'Running Unit Tests on vote app.'
dir(path: 'vote') {
sh 'pip install -r requirements.txt'
sh 'nosetests -v'
}

}
}

stage('vote integration'){
agent any
when{
changeset "**/vote/**"
branch 'master'
}
steps{
echo 'Running Integration Tests on vote app'
dir('vote'){
sh 'sh integration_test.sh'
}
}
}


stage('vote-docker-package') {
agent any
steps {
echo 'Packaging vote app with docker'
script {
docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') {
// ./vote is the path to the Dockerfile that Jenkins will find from the Github repo
def voteImage = docker.build("ibrahimmohamedi/vote:${env.GIT_COMMIT}", "./vote")
voteImage.push()
voteImage.push("${env.BRANCH_NAME}")
voteImage.push("latest")
}
}

}
}


stage('Sonarqube') {
agent any
when{
branch 'master'
}
// tools {
// jdk "JDK11" // the name you have given the JDK installation in Global Tool Configuration
// }

environment{
sonarpath = tool 'SonarScanner'
}

steps {
echo 'Running Sonarqube Analysis..'
withSonarQubeEnv('sonar-instavote') {
sh "${sonarpath}/bin/sonar-scanner -Dproject.settings=sonar-project.properties -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.HEARTBEAT_CHECK_INTERVAL=86400"
}
}
}


stage("Quality Gate") {
steps {
timeout(time: 1, unit: 'HOURS') {
// Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails
// true = set pipeline to UNSTABLE, false = don't
waitForQualityGate abortPipeline: true
}
}
}

stage('deploy to dev') {
agent any
when {
branch 'master'
}
steps {
echo 'Deploy instavote app with docker compose'
sh 'docker-compose up -d'
}
}

}

post {
always {
echo 'Building mono pipeline for voting app is completed.'
}
}
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ Note
----

The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.
http://34.88.80.156:8080/buildStatus/icon?job=instavote%2Fworker-build
++++++
+
42 changes: 42 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
volumes:
db-data:

networks:
instavote:
driver: bridge

services:
vote:
image: ibrahimmohamedi/vote:latest
build: ./vote
ports:
- 5000:80
depends_on:
- redis
networks:
- instavote
redis:
image: redis:alpine
networks:
- instavote
db:
image: postgres:9.4
volumes:
- "db-data:/var/lib/postgressql/data"
networks:
- instavote
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
result:
image: ibrahimmohamedi/result:latest
build: ./vote
ports:
- 5001:4000
worker:
image: ibrahimmohamedi/worker:latest
build: ./vote
depends_on:
- redis
- db
networks:
- instavote
5 changes: 3 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Uncomment and update Org matching your configurations on Sonarcloud
sonar.organization=your-org
sonar.projectKey=your-org_example-voting-app
sonar.organization=ibrahimmohamedi
sonar.projectKey=IbrahimMohamedi_LFS261-example-voting-app
sonar.projectName=Instavote AIO
sonar.projectVersion=1.0
# Comma-separated paths to directories with sources (required)
Expand All @@ -9,3 +9,4 @@ sonar.sources=worker
sonar.sourceEncoding=UTF-8
sonar.java.binaries=.
#sonar.coverage.jacoco.xmlReportPaths=worker/target
# comment
4 changes: 2 additions & 2 deletions vote/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import random
import json

option_a = os.getenv('OPTION_A', "Emacs")
option_b = os.getenv('OPTION_B', "Vi")
option_a = os.getenv('OPTION_A', "Cats")
option_b = os.getenv('OPTION_B', "Dogs")
hostname = socket.gethostname()
version = 'v1'

Expand Down
6 changes: 6 additions & 0 deletions worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM maven:3.6.1-jdk-8-slim
WORKDIR /app
COPY . .
RUN mvn package && \
mv target/worker-jar-with-dependencies.jar /run/worker.jar && rm -rf /app/*
CMD java -jar /run/worker.jar
Loading