Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4ed8877
added application info
norahalr Jul 20, 2025
6c52a84
Merge pull request #1 from norahalr/readme
norahalr2 Jul 20, 2025
990ffa7
added Jenkinsfile for worker with build job
norahalr Jul 20, 2025
5da7700
added Test and package job for worker pipeline
norahalr Jul 20, 2025
a1fe8db
added Test and package job for worker pipeline
norahalr Jul 20, 2025
93702d8
adding Jenkinsfile for result app
norahalr Jul 21, 2025
344171a
adding mock test
norahalr Jul 21, 2025
7eb39e8
add docker based agent
norahalr Jul 21, 2025
a5e811d
adding Dockerfile for worker
norahalr Jul 21, 2025
bed2ac7
Added Docker build stage to Jenkinsfile
norahalr Jul 21, 2025
7f5babc
per stage agents, conditional execution
norahalr Jul 21, 2025
ff57944
Added Dockerfiles and Jenkinsfiles for vote/result
norahalr Jul 21, 2025
78794d2
adding docker compose spec
norahalr Jul 22, 2025
423d68e
all
norahalr Jul 22, 2025
4cacfba
jenkins file
norahalr Jul 22, 2025
d5e90a7
jenkins file
norahalr Jul 22, 2025
ff499bf
update
norahalr Jul 23, 2025
ae51f84
jenkin lab 8
norahalr Jul 24, 2025
2ee379f
Merge pull request #2 from norahalr/feature/monopipe
norahalr Jul 24, 2025
451815b
fkkd
norahalr Jul 24, 2025
1bb3bb0
fkkd
norahalr Jul 24, 2025
3719d07
commint :qa
norahalr Jul 24, 2025
36f90ab
Merge pull request #3 from norahalr/merge-master-temp
norahalr2 Jul 24, 2025
c674282
jinkens
norahalr Jul 24, 2025
a890964
Added Quality Gate and fixed Docker packaging stages
norahalr Jul 24, 2025
eb3482e
Merge branch 'master' of https://github.com/norahalr/LFS261-example-v…
norahalr Jul 24, 2025
f1d44e1
fix: update docker image names to match Docker Hub account
norahalr Jul 24, 2025
f5b75e5
changes
norahalr Jul 24, 2025
1c966ef
docker
norahalr Jul 24, 2025
758981b
fix: make tests.sh executable
norahalr Jul 24, 2025
8a151fc
mess
norahalr Jul 27, 2025
7780958
yay
norahalr Jul 27, 2025
9470d6f
the bash
norahalr Jul 27, 2025
67d0e84
bash
norahalr Jul 27, 2025
dc9a263
norah
norahalr Jul 27, 2025
e752fc9
bash
norahalr Jul 27, 2025
3715217
norah
norahalr Jul 27, 2025
b664da2
norah
norahalr Jul 27, 2025
e0d46e8
norah
norahalr Jul 27, 2025
88dbbe2
norah
norahalr Jul 27, 2025
eff683f
final inshalla
norahalr Jul 27, 2025
4325410
ig
norahalr Jul 27, 2025
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
238 changes: 238 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
pipeline {

agent none

stages {

stage('worker-build') {
agent {
docker {
image 'maven:3.9.8-sapmachine-21'
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.9.8-sapmachine-21'
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.9.8-sapmachine-21'
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("norahns/worker:v${env.BUILD_ID}", './worker')
workerImage.push()
workerImage.push("${env.BRANCH_NAME}")
workerImage.push('latest')
}
}

}
}

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

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

}
}

stage('result-test') {
agent {
docker {
image 'node:22.4.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("norahns/result:v${env.BUILD_ID}", './result')
resultImage.push()
resultImage.push("${env.BRANCH_NAME}")
resultImage.push('latest')
}
}
}
}

stage('vote-build') {
agent {
docker {
image 'python:3.11-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:3.11-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("norahns/vote:${env.GIT_COMMIT}", "./vote")
voteImage.push()
voteImage.push("${env.BRANCH_NAME}")
voteImage.push("latest")
}
}

}
}


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.'
}
}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2 TRY

Example Voting App
=========

Expand Down
55 changes: 55 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
volumes:
db-data:

networks:
instavote:
driver: bridge

services:
vote:
image: norahns/vote:latest
build: ./vote
ports:
- 5000:80
depends_on:
- redis
networks:
- instavote

redis:
image: redis:alpine
networks:
- instavote

db:
image: postgres:15-alpine
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
volumes:
- "db-data:/var/lib/postgresql/data"
- "./healthchecks:/healthchecks"
healthcheck:
test: /healthchecks/postgres.sh
interval: "5s"
networks:
- instavote

result:
image: norahns/result:latest
build: ./result
ports:
- 5001:80
depends_on:
- db
networks:
- instavote

worker:
image: norahns/worker:latest
build: ./worker
depends_on:
- redis
- db
networks:
- instavote
6 changes: 3 additions & 3 deletions e2e/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VOTE_IMAGE=xxxx/vote:latest
WORKER_IMAGE=xxxx/worker:latest
RESULT_IMAGE=xxxx/result:latest
VOTE_IMAGE=norahns/vote:latest
WORKER_IMAGE=norahns/worker:latest
RESULT_IMAGE=norahns/result:latest
Empty file added e2e/tests/=
Empty file.
Empty file added e2e/tests/CACHED
Empty file.
2 changes: 1 addition & 1 deletion e2e/tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ RUN apt-get update -qq && apt-get install -qy \
RUN yarn global add phantomjs-prebuilt
ADD . /app
WORKDIR /app
CMD ./tests.sh
CMD ./tests.sh
Empty file added e2e/tests/[e2e]
Empty file.
Empty file added e2e/tests/exporting
Empty file.
28 changes: 11 additions & 17 deletions e2e/tests/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,42 @@

# Function to get current vote count
get_vote_count() {
phantomjs render.js "http://result:80/" | grep -i vote | cut -d ">" -f 4 | cut -d " " -f1
# Extracts the number of votes like "7 votes" => "7"
phantomjs render.js "http://result:80/" | grep -oE '[0-9]+ votes' | grep -oE '[0-9]+'
}

# Wait for services to be ready
echo "Waiting for services to be ready..."
while ! timeout 1 bash -c "echo > /dev/tcp/vote/80"; do
while ! timeout 1 bash -c "echo > /dev/tcp/vote/80" 2>/dev/null; do
sleep 1
done
echo "Vote service is ready."

while ! timeout 1 bash -c "echo > /dev/tcp/result/80"; do
while ! timeout 1 bash -c "echo > /dev/tcp/result/80" 2>/dev/null; do
sleep 1
done
echo "Result service is ready."

# Get initial vote count
initial_count=$(get_vote_count)

echo "Initial vote count: $initial_count"



# Submit first vote
echo "Submitting vote (a)..."
curl -sS -X POST --data "vote=a" http://vote
curl -sS -X POST --data "vote=a" http://vote > /dev/null
sleep 2

# Get vote count after submission
current=$(get_vote_count)
echo "Vote count after first submission: $current"

# Calculate expected next count
# final=$((initial_count + 1))
# echo "Expected final count: $final"

# Check vote count multiple times
# for i in {1..5}; do
# sleep 2
# Try again if result is unstable or delayed
sleep 2
new=$(get_vote_count)
# done

# Final check
echo "Performing final check..."
if [ $initial_count -lt $new ]; then
if ! [ -z "$initial_count" ] && ! [ -z "$new" ] && [ "$initial_count" -lt "$new" ]; then
echo -e "\e[42m------------"
echo -e "\e[92mTests passed"
echo -e "\e[42m------------"
Expand All @@ -52,6 +46,6 @@ else
echo -e "\e[41m------------"
echo -e "\e[91mTests failed"
echo -e "\e[41m------------"
echo "Expected: $next, Actual: $new"
echo "Expected: greater than $initial_count, Actual: $new"
exit 1
fi
Empty file added e2e/tests/transferring
Empty file.
Loading