Skip to content

Commit

Permalink
Merge pull request #1094 from uhafner/cleanup
Browse files Browse the repository at this point in the history
Cleanup Jenkins Docker setup
  • Loading branch information
uhafner authored Aug 6, 2024
2 parents 112f75c + 894522a commit 6d24010
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 44 deletions.
17 changes: 10 additions & 7 deletions bin/jenkins.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/bin/bash
# Make sure that docker runs with the current UID to avoid permission problems on volume docker/volumes/jenkins-home
CURRENT_UID="$(id -u)"
export CURRENT_UID

docker pull jenkins/jenkins:lts-jdk21
CURRENT_GID="$(id -g)"
export CURRENT_GID

docker compose build --pull
CURRENT_USER="$(id -u):$(id -g)"
export CURRENT_USER

# Make sure that docker runs with the current UID to avoid permission problems on volume docker/volumes/jenkins-home
CURRENT_UID="$(id -u):$(id -g)"
export CURRENT_UID
echo Running docker compose with user ID $CURRENT_UID
echo Running docker compose with user ID $CURRENT_USER

docker pull jenkins/jenkins:lts-jdk21
docker compose build --pull
docker compose up --always-recreate-deps
10 changes: 5 additions & 5 deletions doc/uml/class-diagram-technical.puml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ skinparam package {
BackgroundColor<<Main>> gold
BorderColor black
ArrowColor black
FontName Arial Unicode MS
FontName Arial Unicode MS
FontSize 20
}

Expand All @@ -16,7 +16,7 @@ skinparam class {
BackgroundColor<<Main>> gold
BorderColor black
ArrowColor black
FontName Arial Unicode MS
FontName Arial Unicode MS
FontSize 20
}
skinparam classFontSize 24
Expand Down Expand Up @@ -50,7 +50,7 @@ note "Vererbung" as Vererbung
note "Implementierung" as Implementierung
note "gerichtete Assoziation" as Assoziation
note "generischen Typ binden" as Generics
note "gerichtete Abhängigkeit" as Dependency
note "gerichtete Abhängigkeit:\n<<use>> benutzt\n<<create>> erzeugt\n<<call>> Aufruf" as Dependency

class ConcreteObservable {
-concreteState: State
Expand Down Expand Up @@ -97,8 +97,8 @@ Observer <|.. AbstractObserver
AbstractObserver <|-- ConcreteObserver : <<bind>> \n<T -> ConcreteObserver>
ConcreteObservable <-left- ConcreteObserver : \t\t

java .up. Package
util .up. Subpackage
java .right. Package
util .down. Subpackage
Observable .up. Class
Observable .. Vererbung
ConcreteObservable .up. Vererbung
Expand Down
23 changes: 10 additions & 13 deletions doc/uml/component-diagram-overview.puml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ skinparam component {
BorderColor black
FontName Arial Unicode MS
FontSize 20
ArrowFontName Arial Unicode MS
ArrowFontName Arial Unicode MS
ArrowFontSize 18
}

Expand Down Expand Up @@ -42,27 +42,24 @@ anwendung .up.> library : " <<use>>"
note "Artefakt" as artefact
note "Komponente" as component
note "Schnittstelle" as schnittstelle
note "Implementierung" as Implementierung
note "Aufruf" as Use
note "gerichtete Abhängigkeit" as Dependency

circle " \t\t\t Fassade " as fassade
circle "RestApi " as api
note "Implementierung\neiner Schnittstelle" as Implementierung
note "Aufruf einer\nSchnittstelle" as Use
note "gerichtete Abhängigkeit\nohne Angabe Interface" as Dependency

circle "\t Fassade " as fassade

anwendung ..> fassade : " <<use>>"
fassade -- fachkomponente
fassade -up- fachkomponente

anwendung .down. Use
fassade .up. Use

api .up. schnittstelle
fassade .left. schnittstelle
library .up. component
lang .left. artefact
lang .down. artefact

anwendung -up- api : " "
api .down. Implementierung
anwendung .right. Implementierung
fassade .down. Implementierung
fachkomponente .right. Implementierung

anwendung .up. Dependency
library .down. Dependency
Expand Down
5 changes: 2 additions & 3 deletions doc/uml/deployment-diagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ skinparam artifact {
BackgroundColor #e4e4e4
BorderColor #a0a0a0
ArrowColor black
FontName Arial Unicode MS
FontName Arial Unicode MS
FontSize 20
StereotypeFontSize 14
}


node ":MacBook" <<device>> {
node ":macOS Monterey" <<execution environment>> {
node ":Safari 15.4" <<execution environment>> {
Expand Down Expand Up @@ -62,7 +61,7 @@ note "Execution Environment" as env
":Server" .. channel
":MacBook" .. channel

W .right. artifact
C .left. artifact


@enduml
3 changes: 2 additions & 1 deletion doc/uml/sequence-diagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ skinparam actor {
BackgroundColor<<Main>> gold
BorderColor black
ArrowColor black
FontName Arial Unicode MS
FontName Arial Unicode MS
FontSize 20

LifeLineBorderColor black
Expand All @@ -50,6 +50,7 @@ participant "blau:ZweiteKlasse" as blau
activate unnamed
Akteur -> unnamed: start(1, 3, 2)
create rot

unnamed -->> rot : new
unnamed -> rot: synchronerAufruf({1, 3, 2})
activate rot
Expand Down
12 changes: 9 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ services:
container_name: codingstyle-jenkins
build:
context: docker/images/jenkins-controller
args:
- CURRENT_UID=${CURRENT_UID}
- CURRENT_GID=${CURRENT_GID}
image: codingstyle/jenkins-controller
volumes:
- ./docker/volumes/jenkins-home:/var/jenkins_home # Mounts the local jenkins_home volume to the /var/jenkins_home path inside the container
Expand All @@ -14,7 +17,7 @@ services:
environment:
- TRY_UPGRADE_IF_NO_MARKER=true
- JAVA_OPTS= -Dstapler.jelly.noCache=true -Dhudson.remoting.ClassFilter=com.google.common.collect.ImmutableListMultimap -DexecutableWar.jetty.disableCustomSessionIdCookieName=true -DexecutableWar.jetty.sessionIdCookieName=codingstyle
user: ${CURRENT_UID}
user: ${CURRENT_USER}
restart: unless-stopped
depends_on:
key-generator:
Expand Down Expand Up @@ -47,7 +50,11 @@ services:

java-agent:
container_name: codingstyle-java-agent
build: docker/images/java-agent
build:
context: docker/images/java-agent
args:
- CURRENT_UID=${CURRENT_UID}
- CURRENT_GID=${CURRENT_GID}
image: codingstyle/java-agent
depends_on:
key-generator:
Expand All @@ -63,7 +70,6 @@ services:
retries: 5
volumes:
- agent-ssh-dir:/home/jenkins/.ssh:ro # Mounts the agent-ssh-dir volume to the /home/jenkins/.ssh path inside the container as read-only
- ${HOME}/.m2/repository:/home/jenkins/.m2/repository # Mounts the local Maven repository to the /home/jenkins/.m2 path inside the container

volumes:
agent-ssh-dir:
Expand Down
5 changes: 4 additions & 1 deletion docker/images/java-agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ RUN curl -sS -L -O --output-dir /tmp/ --create-dirs https://archive.apache.org/
export PATH=${M2_HOME}/bin:${PATH}" > /etc/profile.d/maven.sh
ENV M2_HOME="/opt/maven"
ENV PATH="${M2_HOME}/bin/:${PATH}"
RUN echo "PATH=${PATH}" >> /etc/environment && chown -R jenkins:jenkins "${JENKINS_AGENT_HOME}"

RUN echo "PATH=${PATH}" >> /etc/environment && \
mkdir -pv "${JENKINS_AGENT_HOME}/.m2/repository" && \
chown -R jenkins:jenkins "${JENKINS_AGENT_HOME}"
2 changes: 1 addition & 1 deletion src/main/java/edu/hm/hafner/util/FilteredLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/**
* Provides a log of info messages and a limited number of error messages. If the number of errors exceeds this limit,
* then subsequent error messages will be skipped. This class is thread-safe and can be used in a distributed
* then further error messages will be skipped. This class is thread-safe and can be used in a distributed
* environment.
*
* @author Ullrich Hafner
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/hm/hafner/util/Generated.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* This annotation is used to mark source code that has been generated or is somehow not relevant for style checking or
* code coverage analysis. It is quite similar to the {@code javax.annotation.Generated} annotation. The
* main difference is that it has class retention on so is available for tools that work on bytecode (like JaCoCo,
* main difference is that it has class retention, so it is available for tools that work on bytecode (like JaCoCo,
* PIT, or SpotBugs).
*/
@Retention(CLASS)
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/edu/hm/hafner/util/PathUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import edu.umd.cs.findbugs.annotations.CheckForNull;

/**
* Utilities for {@link Path} instances.
* Utilities for {@link Path} instances. These methods handle file paths in Windows and Unix file system
* implementations transparently. Moreover, these methods do not throw exceptions when illegal paths are specified.
*
* @author Ullrich Hafner
*/
Expand Down Expand Up @@ -71,7 +72,7 @@ public boolean exists(final String fileName, final String directory) {

/**
* Returns the string representation of the specified path. The path will be actually resolved in the file system
* and will be returned as fully qualified absolute path. In case of an error, i.e. if the file is not found, the
* and will be returned as a fully qualified absolute path. In case of an error, i.e., if the file is not found, the
* provided {@code path} will be returned unchanged (but normalized using the UNIX path separator and upper case
* drive letter).
*
Expand All @@ -91,7 +92,7 @@ public String getAbsolutePath(final String path) {

/**
* Returns the string representation of the specified path. The path will be actually resolved in the file system
* and will be returned as fully qualified absolute path. In case of an error, i.e. if the file is not found, the
* and will be returned as a fully qualified absolute path. In case of an error, i.e., if the file is not found, the
* provided {@code path} will be returned unchanged (but normalized using the UNIX path separator and upper case
* drive letter).
*
Expand Down Expand Up @@ -140,7 +141,7 @@ public String getRelativePath(final Path base, final String path) {
* UNIX path separator and upper case drive letter).
*
* @param base
* the base directory that should be to get the absolute path for
* the base directory that should be to get the absolute path for
* @param path
* the path to get the absolute path for
*
Expand All @@ -163,7 +164,7 @@ public String getRelativePath(final String base, final String path) {
* UNIX path separator and upper case drive letter).
*
* @param base
* the base directory that should be to get the absolute path for
* the base directory that should be to get the absolute path for
* @param path
* the path to get the absolute path for
*
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/edu/hm/hafner/util/SecureXmlParserFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void parse(final Reader reader, final Charset charset, final DefaultHandl
* @param charset
* the charset to use when reading the content
*
* @return the file content as document
* @return the file content as a document
* @throws ParsingException
* if the file could not be parsed
*/
Expand All @@ -306,8 +306,10 @@ public Document readDocument(final Reader reader, final Charset charset) {
}
}

private InputSource createInputSource(final Reader reader, final Charset charset) {
return new InputSource(new ReaderInputStream(reader, charset));
private InputSource createInputSource(final Reader reader, final Charset charset) throws IOException {
var inputStream = ReaderInputStream.builder().setReader(reader).setCharset(charset).get();

return new InputSource(inputStream);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/hm/hafner/util/TreeStringBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/**
* Builds {@link TreeString}s that share common prefixes. Call {@link #intern(String)} and you get the {@link
* TreeString} that represents the same string, but as you interns more strings that share the same prefixes, those
* TreeString} that represents the same string, but as you intern more strings that share the same prefixes, those
* {@link TreeString}s that you get back start to share data.
*
* <p>
Expand Down

0 comments on commit 6d24010

Please sign in to comment.