mvn-build-pipeline - #24
Conversation
| return 1 | ||
| } | ||
|
|
||
| generate_project_whitelist() { |
There was a problem hiding this comment.
This function stores the specified project names in the configuration (eager loading). The whitelist acts as a filter to prevent including POM files from different subdirectories that happen to share the same name.
For example, in my setup I created a test project called complete_dwh that aggregates all DWH modules. When the script runs, those modules would also be detected and could interfere with the pipeline. The whitelist ensures that only the intended projects are considered.
akomii
left a comment
There was a problem hiding this comment.
See comments attached. Do we have somewhere the intended purpose of this script written down?
| # start a new ssh session | ||
| ssh -o ControlMaster=auto -o ControlPersist=5m -o ControlPath="$ctl" -Nf "$host" | ||
| # copy ear to target host | ||
| scp -o ControlPath="$ctl" "$ear_path" "$host:/tmp/$ear_name" | ||
| ssh -o ControlPath="$ctl" "$host" "$remote_cmd" | ||
| ssh -O exit -o ControlPath="$ctl" "$host" |
There was a problem hiding this comment.
Likewise for docker, to avoid repeated authentication input from user
| # Currently Wildfly seems to automatically deploy the ear when copied to this directory. | ||
| remote_cmd+="sudo docker cp /tmp/$ear_name $wildfly_container:/opt/wildfly/standalone/deployments/ ; " |
There was a problem hiding this comment.
You could just stop the Wildfly, clean the deployments, put in the new ones and restart wildfly
There was a problem hiding this comment.
I could not find a wildfly service inside the docker container to use:
$ service wildfly restart
wildfly: unrecognized service
Systemctl is not available as well so JBoss-CLI was the next option to try
There was a problem hiding this comment.
systemd is not available on docker. What I meant was on a container basis. The DEV_MODE opens up the wildfly deployments folder on the host. You could stop the container, switch out the deployments and restart the container afterwards
| ssh -o ControlMaster=auto -o ControlPersist=5m -o ControlPath="$ctl" -Nf "$host" | ||
| scp -o ControlPath="$ctl" "$ear_path" "$host:/tmp/$ear_name" | ||
| ssh -o ControlPath="$ctl" "$host" "$remote_cmd" | ||
| ssh -O exit -o ControlPath="$ctl" "$host" |
There was a problem hiding this comment.
This starts a ssh session to the target system. If each command would be executed on its own, each time it would require a new password authentication because each command would start a new terminal
| git_resolve_module_to_commit() { | ||
| # This function returns the last commit containing the artifact-version pair | ||
| local artifact="$1" | ||
| local version="$2" | ||
|
|
||
| local target_path | ||
| target_path="$(resolve_artifact_to_pom "$artifact")" | ||
|
|
||
| if [[ -z "$target_path" ]]; then | ||
| log_error "No artifact '$artifact' found inside project pom-files" | ||
| return 1 | ||
| fi | ||
| log_info "Found artifact '$artifact' inside '$target_path'" | ||
|
|
||
| local target_dir relative_path | ||
| target_dir="$(dirname "$target_path")" | ||
| relative_path="$(git -C "$target_dir" rev-parse --show-prefix)pom.xml" | ||
|
|
||
| # Search commit containing the requested artifact version | ||
| local commit | ||
| commit="$(resolve_to_commit "$target_dir" "$version" "$relative_path")" | ||
|
|
||
| if [[ -z "$commit" ]]; then | ||
| log_error "Did not find '$artifact:$version'" | ||
| fi | ||
|
|
||
| printf '%s:%s\n' "$target_path" "$commit" |
There was a problem hiding this comment.
Not sure if Git is here just overkill. Maybe just focus the scope on local builds? Let the users decide themselves, which branches to use for the build. The script should only align the current local branch versions
There was a problem hiding this comment.
Users can already use branches as identifiers for builds.
I think it would be a good idea to assess the requirements on this script. At this complexity it could make more sense to use the script in a CICD pipeline as a test stage, for analyzing the dependency structure of the project.
The reason for this script to be created was that the production branch of the project had misaligning dependencies. Restricting this scripts' scope to local builds like i understand it, would be just a minor improvement of already existing scripts and would also not fix the core issue coming from the dependencies.
| if [[ "$rm_packages" == "true" ]]; then | ||
| echo "[WARN] Removing all packages from local Maven installations" | ||
| if [[ -d "$HOME/.m2/repository/org/aktin" ]]; then | ||
| rm -rf ~/.m2/repository/org/aktin | ||
| echo "[INFO] Removed artifacts from local maven store" | ||
| else | ||
| echo "[INFO] No Local maven store found, skipping." | ||
| fi | ||
| fi |
There was a problem hiding this comment.
I dont really get it. mvn install builds the artifact and copies into the local maven repository.
How can it happen that a dependency is not being build?
Therefore dependencies are still being loaded from the local repository and will not be build.
I dont understand this sentence
| # Currently Wildfly seems to automatically deploy the ear when copied to this directory. | ||
| remote_cmd+="sudo docker cp /tmp/$ear_name $wildfly_container:/opt/wildfly/standalone/deployments/ ; " |
There was a problem hiding this comment.
systemd is not available on docker. What I meant was on a container basis. The DEV_MODE opens up the wildfly deployments folder on the host. You could stop the container, switch out the deployments and restart the container afterwards
| -p, --server-ip <IP> Target server IP / host. | ||
| --set-java-8 <PATH> Path to installed Java SDK 8. | ||
| --set-java-11 <PATH> Path to installed Java SDK 11. |
There was a problem hiding this comment.
switch server ip with the set-java (better styling)
| -b, --build-from <NAME> Start building from the given project name. | ||
| Default: build all configured projects. | ||
|
|
||
| -d, --project-dir <DIR> Root directory that contains the project folders. | ||
| -d, --project-dir <DIR> Root directory containing project folders. | ||
| Default: current working directory. | ||
|
|
||
| -c, --config <FILE> Path to config file to load projects array from. | ||
| Default: ./projects.conf (will be copied to ./script-config.conf) | ||
|
|
||
| -r, --remove-packages Remove local Maven artifacts under ~/.m2/repository/org/aktin | ||
| before building. | ||
| Default: false | ||
| -c, --config <FILE> Config file containing project list. | ||
| Default: ./projects.conf (copied to ./script-config.conf) | ||
|
|
||
| -i, --instance <NAME> Instance/environment selector. | ||
| Default: debian, Options: debian, docker | ||
| -r, --remove-packages Remove local Maven artifacts under | ||
| ~/.m2/repository/org/aktin before build. | ||
|
|
||
| -w, --wildfly <NAME> Name of Wildfly container. Required if instance is set to "docker". | ||
| -i, --instance <NAME> Environment selector. | ||
| Options: debian, docker (default: debian) | ||
|
|
||
| -h, --help Show this help and exit. | ||
| -w, --wildfly <NAME> Wildfly container name (required for docker). |
There was a problem hiding this comment.
Add also in the desc, which of these arguments are optional, i.e.
-c, --config <FILE> (optional) Path to config file to load projects array from.
Default: ./projects.conf (will be copied to ./script-config.conf)
Shell build pipeline for building and serving a AKTIN data warehouse. Builds project modules local and resolves module dependencies by searching project commits. The pipeline assembler uses a commit-id based system, making module targeting precise and pipeline configuration flexible.
Still some todos inside script but tests were good. I tested on a ubuntu 22 system and build the default configuration inside the repository, that receives only the latest release tag "v1.6rc1". Target was a VM with debian instance of AKTIN data warehouse.