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

to update everything #185

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
15678da
Update pom.xml
jmmoralesc Aug 13, 2024
b44ec22
Create test.jmc
jmmoralesc Aug 15, 2024
d4b44c7
Create jmc2.test
jmmoralesc Aug 15, 2024
a12d97c
Create webhook2.test
jmmoralesc Aug 15, 2024
42cd4ff
Create Jenkinsfile
jmmoralesc Aug 22, 2024
738836a
Merge pull request #3 from jmmoralesc/jenkinsfile
jmmoralesc Aug 22, 2024
cb9ac80
Update Jenkinsfile
jmmoralesc Aug 22, 2024
3709053
Merge pull request #4 from jmmoralesc/testmulti
jmmoralesc Aug 22, 2024
559a681
added application info
jmmoralesc Aug 23, 2024
c719ac5
Merge pull request #7 from jmmoralesc/readme
jmmoralesc Aug 23, 2024
e8a4f09
added Jenkinsfile and backup for worker build job
jmmoralesc Aug 23, 2024
42ed748
Update Jenkinsfile maven version
jmmoralesc Aug 23, 2024
ab35eaf
Update Jenkinsfile
jmmoralesc Aug 23, 2024
15cd5b5
Merge pull request #9 from jmmoralesc/jmmoralesc-patch-3
jose-morales-cubillo Aug 23, 2024
4b782e2
Update Jenkinsfile
jmmoralesc Aug 23, 2024
211d948
added test and package job for worker pipeline
jmmoralesc Aug 23, 2024
f0807e8
Merge branch 'feature/workerpipe' of https://github.com/jmmoralesc/LF…
jmmoralesc Aug 23, 2024
0303c03
Update Jenkinsfile
jmmoralesc Aug 23, 2024
2b42ec2
Update Jenkinsfile - add conditional for worker path
jmmoralesc Aug 23, 2024
f0f13cf
Update README.md - testing worker pipelines
jmmoralesc Aug 23, 2024
acf4703
Merge branch 'master' into feature/workerpipe
jose-morales-cubillo Aug 23, 2024
0697096
Merge pull request #10 from jmmoralesc/feature/workerpipe
jose-morales-cubillo Aug 23, 2024
5ea3bf8
add docker based agent to Jenkinsfile
jmmoralesc Aug 28, 2024
12c47c3
Merge pull request #11 from jmmoralesc/feature/dockerbuild
jose-morales-cubillo Aug 28, 2024
82fab00
Update Jenkinsfile - with new instructions
jmmoralesc Aug 30, 2024
00ca9e9
Merge pull request #13 from jmmoralesc/jmmoralesc-patch-1
jose-morales-cubillo Aug 30, 2024
9176211
Update Jenkinsfile
jmmoralesc Aug 30, 2024
d06304e
Merge pull request #14 from jmmoralesc/jmmoralesc-patch-2
jose-morales-cubillo Aug 30, 2024
4918087
adding docker compose and Dockerfile
jmmoralesc Sep 3, 2024
12769f1
Update Jenkinsfile
jmmoralesc Sep 4, 2024
033c63f
Update Jenkinsfile
jose-morales-cubillo Sep 4, 2024
7cdc8d6
Update Jenkinsfile
jose-morales-cubillo Sep 4, 2024
bffdd2f
Update Jenkinsfile
jose-morales-cubillo Sep 4, 2024
1930483
Update Jenkinsfile
jose-morales-cubillo Sep 4, 2024
d865a83
Update Jenkinsfile - SonarQube
jmmoralesc Sep 27, 2024
eae7c61
Update sonar-project.properties
jmmoralesc Sep 27, 2024
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.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("xxxxx/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("xxxxx/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("xxxxx/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.'
}
}
}

11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Example Voting App
Voting App
=========

Getting started
Expand Down Expand Up @@ -58,3 +58,12 @@ 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.


Note:
Example Voting App
=========
This is a sample voting app

Testing the commits
====
52 changes: 52 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
volumes:
db-data:

networks:
instavote:
driver: bridge

services:
vote:
image: jmmoralesc/vote:latest
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: jmmoralesc/result:latest
ports:
- 5001:4000
depends_on:
- db
networks:
- instavote

worker:
image: jmmoralesc/worker:latest
depends_on:
- redis
- db
networks:
- instavote
6 changes: 3 additions & 3 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Uncomment and update Org matching your configurations on Sonarcloud
sonar.organization=your-org
sonar.projectKey=your-org_example-voting-app
sonar.projectName=Instavote AIO
sonar.organization=jmmoralesc
sonar.projectKey=jmmoralesc_LFS261-example-voting-app
sonar.projectName=Instavote AIO LFS261examplevotingapp
sonar.projectVersion=1.0
# Comma-separated paths to directories with sources (required)
sonar.sources=worker
Expand Down
1 change: 1 addition & 0 deletions test.jmc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a test file
27 changes: 9 additions & 18 deletions vote/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,20 @@
FROM python:3.11-slim AS base

# Add curl for healthcheck
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*
#RUN apt-get update && \
# apt-get install -y --no-install-recommends curl && \
# rm -rf /var/lib/apt/lists/*

# Set the application directory
WORKDIR /usr/local/app
WORKDIR /app

# Install our requirements.txt
COPY requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
#COPY requirements.txt ./requirements.txt
ADD requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt

# Define a stage specifically for development, where it'll watch for
# filesystem changes
FROM base AS dev
RUN pip install watchdog
ENV FLASK_ENV=development
CMD ["python", "app.py"]

# Define the final stage that will bundle the application for production
FROM base AS final

# Copy our code from the current folder to the working directory inside the container
COPY . .
#Copy our code from the current folder to /app inside the container
ADD . /app

# Make port 80 available for links and/or publish
EXPOSE 80
Expand Down
Loading