Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Use the official Gradle image with JDK 11 as the base image
FROM gradle:7.6.1-jdk11

# Set the working directory inside the container
WORKDIR /desktop_app

# Copy the Gradle build script into the container
COPY build.gradle ./

# Copy the Gradle wrapper scripts into the container
COPY gradlew gradlew.bat ./

# Copy the Gradle folder containing wrapper files
COPY gradle ./gradle

# Copy all other project files into the container
COPY . .

# Give execution permission to the Gradle wrapper script
RUN chmod +x ./gradlew

# Expose port 8080 for external access to the application
EXPOSE 8080

# Start the application using the Gradle wrapper,
# with "--continuous" to automatically rebuild on file changes
CMD ["./gradlew", "appRun", "--continuous"]
#Fixing appRun because gradle is case sensitive
105 changes: 105 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// This jenkinsfile is used to run CI/CD on my local (Windows) box, no VM's needed.
pipeline {
agent any
tools {
jdk 'Java 17'
gradle 'Gradle 7.6'
}

environment {
// This is set so that the Python API tests will recognize it
// and go through the Zap proxy waiting at 9888
HTTP_PROXY = 'http://127.0.0.1:9888'
// Default Java Home for Jenkins (JDK 17)
JAVA_HOME = '/usr/lib/jvm/java-17-openjdk'
PATH = "${JAVA_HOME}/bin:${PATH}"
}

stages {

stage('Docker Access Test') {
steps {
sh 'docker ps'
}
}
// build the war file (the binary). This is the only
// place that happens.
stage('Build') {
environment {
// Override JAVA_HOME to use JDK 11 for this stage
JAVA_HOME = '/usr/lib/jvm/java-11-openjdk'
PATH = "${JAVA_HOME}/bin:${PATH}"
}
steps {
sh 'docker build -t ensf400project1 .'
}
}
// run all the unit tests - these do not require anything else
// to be running and most run very quickly.
stage('Unit Tests') {
environment {
// Override JAVA_HOME to use JDK 11 for this stage
JAVA_HOME = '/usr/lib/jvm/java-11-openjdk'
PATH = "${JAVA_HOME}/bin:${PATH}"
}
steps {
sh './gradlew test'
}
post {
always {
junit 'build/test-results/test/*.xml'
}
}
}
// // run the tests which require connection to a
// // running database.
// stage('Database Tests') {
// environment {
// // Override JAVA_HOME to use JDK 11 for this stage
// JAVA_HOME = '/usr/lib/jvm/java-11-openjdk'
// PATH = "${JAVA_HOME}/bin:${PATH}"
// }
// steps {
// sh './gradlew integrate'
// }
// post {
// always {
// junit 'build/test-results/integrate/*.xml'
// }
// }
// }
// // These are the Behavior Driven Development (BDD) tests
// // See the files in src/bdd_test
// // These tests do not require a running system.
// stage('BDD Tests') {
// environment {
// // Override JAVA_HOME to use JDK 11 for this stage
// JAVA_HOME = '/usr/lib/jvm/java-11-openjdk'
// PATH = "${JAVA_HOME}/bin:${PATH}"
// }
// steps {
// sh './gradlew generateCucumberReports'
// // generate the code coverage report for jacoco
// sh './gradlew jacocoTestReport'
// }
// post {
// always {
// junit 'build/test-results/bdd/*.xml'
// }
// }
// }
// Runs an analysis of the code, looking for any
// patterns that suggest potential bugs.
stage('Static Analysis') {
environment {
// Override JAVA_HOME to use JDK 11 for this stage
JAVA_HOME = '/usr/lib/jvm/java-11-openjdk'
PATH = "${JAVA_HOME}/bin:${PATH}"
}

steps{
sh './gradlew sonarqube -Dsonar.host.url=http://localhost:9000 -Dsonar.login=admin -Dsonar.password=ensf400'
}
}
}
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#orginal readme file from existing repo


## Demo - demonstrates an application and tests

This is an application by [Coveros](https://www.coveros.com/) to demonstrate good
Expand Down
Binary file added Screenshots/Docker_Desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Local_Browser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Rest_of_Terminal1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Terminal1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ plugins {

// gretty is a gradle plugin to make it easy to run a server and hotswap code at runtime.
// https://plugins.gradle.org/plugin/org.gretty
id 'org.gretty' version '3.0.4'
id 'org.gretty' version '3.1.5'

// provides access to a database versioning tool.
id "org.flywaydb.flyway" version "6.0.8"
Expand Down Expand Up @@ -63,6 +63,8 @@ plugins {

java {
toolchain {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
languageVersion.set(JavaLanguageVersion.of(11))
}
}
Expand Down
50 changes: 50 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
services:
jenkins:
build: ./jenkins
privileged: true
user: root
ports:
- 8080:8080
- 50000:50000
container_name: jenkins
volumes:
- /home/codespace:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
networks:
- dev-network
depends_on:
- sonarqube

sonarqube:
image: sonarqube:8.9-community
container_name: sonarqube
environment:
- SONARQUBE_JDBC_URL=jdbc:postgresql://db:5432/sonar
- SONARQUBE_JDBC_USERNAME=sonar
- SONARQUBE_JDBC_PASSWORD=sonar
ports:
- "9000:9000"
volumes:
- sonarqube_data:/opt/sonarqube/data
networks:
- dev-network

db:
image: postgres:latest
container_name: sonar-db
environment:
- POSTGRES_USER=sonar
- POSTGRES_PASSWORD=sonar
- POSTGRES_DB=sonar
volumes:
- db_data:/var/lib/postgresql/data
networks:
- dev-network

networks:
dev-network:

volumes:
jenkins_home:
sonarqube_data:
db_data:
Binary file modified docs/BDD_video.mp4
Binary file not shown.
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ org.gradle.workers.max=1

# Setting the memory config explicitly
org.gradle.jvmargs=-Xmx1g -XX:MaxMetaspaceSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

#Adding compatible java version path
#org.gradle.java.home=C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.6.7-hotspot
29 changes: 29 additions & 0 deletions jenkins/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM jenkins/jenkins:alpine
# switch to root user
USER root

# install docker on top of the base image
RUN apk add --update docker openrc

# Install Gradle dependencies
RUN apk add --no-cache \
openjdk11 \
bash \
docker \
curl \
unzip

# Set Gradle version
ENV GRADLE_VERSION=7.6
ENV GRADLE_HOME=/opt/gradle
# Download and install Gradle
RUN mkdir -p ${GRADLE_HOME} && \
curl -fsSL https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip -o /tmp/gradle.zip && \
unzip /tmp/gradle.zip -d /opt/gradle && \
rm /tmp/gradle.zip

# Add Gradle to PATH
ENV PATH="${GRADLE_HOME}/gradle-${GRADLE_VERSION}/bin:${PATH}"

# Verify installation
RUN gradle -v
Loading