Skip to content

Commit

Permalink
Change path to ~/.m2/org/opensearch/plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mcasas993 committed Nov 14, 2024
1 parent 2fead7a commit cbd4cf0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 41 deletions.
38 changes: 20 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ jobs:
build:
needs: [matrix, build-wazuh-plugins, build-reporting-plugin]
runs-on: ${{ matrix.architecture == 'arm64' && 'wz-linux-arm64' || 'ubuntu-22.04' }}
env:
maven_local_path: ~/.m2/org/opensearch/plugin
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
Expand Down Expand Up @@ -278,20 +280,20 @@ jobs:
echo "versionOpenSearch_inBuild=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: PRE Cache ~/.m2/repository/org/opensearch
id: pre-assemble-cache-m2-repository-opensearch-plugins
- name: PRE Cache ${{ env.maven_local_path }}
id: pre-assemble-cache-m2-opensearch-plugins
uses: actions/cache@v4
with:
path: |
~/.m2/repository/org/opensearch
key: ${{ runner.os }}-m2-repository-opensearch-${{ hashFiles('**.xml') }}
${{ env.maven_local_path }}
key: ${{ runner.os }}-m2-opensearch-plugin-${{ hashFiles('**.sha1') }}
restore-keys: |
${{ runner.os }}-m2-repository-opensearch-
${{ runner.os }}-m2-repository-opensearch
${{ runner.os }}-m2-opensearch-plugin-
${{ runner.os }}-m2-opensearch-plugin
- if: ${{steps.pre-assemble-cache-m2-repository-opensearch-plugins.outputs.cache-hit == 'true'}}
name: PRE Cache ~/.m2/repository/org/opensearch success
run: ls -la ~/.m2/repository/org/opensearch
- if: ${{steps.pre-assemble-cache-m2-opensearch-plugins.outputs.cache-hit == 'true'}}
name: PRE Cache ${{ env.maven_local_path }} success
run: ls -la ${{ env.maven_local_path }}

- name: Run `assemble.sh`
run: |
Expand All @@ -300,20 +302,20 @@ jobs:
-d ${{ matrix.distribution }} \
-r ${{ inputs.revision }}
- name: POST Cache ~/.m2/repository/org/opensearch
id: post-assemble-cache-m2-repository-opensearch-plugins
- name: POST Cache ${{ env.maven_local_path }}
id: post-assemble-cache-m2-opensearch-plugins
uses: actions/cache@v4
with:
path: |
~/.m2/repository/org/opensearch
key: ${{ runner.os }}-m2-repository-opensearch-${{ hashFiles('**.xml') }}
${{ env.maven_local_path }}
key: ${{ runner.os }}-m2-opensearch-plugin-${{ hashFiles('**.sha1') }}
restore-keys: |
${{ runner.os }}-m2-repository-opensearch-
${{ runner.os }}-m2-repository-opensearch
${{ runner.os }}-m2-opensearch-plugin-
${{ runner.os }}-m2-opensearch-plugin
- if: ${{steps.pre-assemble-cache-m2-repository-opensearch-plugins.outputs.cache-hit == 'true'}}
name: POST Cache ~/.m2/repository/org/opensearch success
run: ls -la ~/.m2/repository/org/opensearch
- if: ${{steps.post-assemble-cache-m2-opensearch-plugins.outputs.cache-hit == 'true'}}
name: POST Cache ${{ env.maven_local_path }} success
run: ls -la ${{ env.maven_local_path }}

- name: Test RPM package
if: ${{ matrix.distribution == 'rpm' }}
Expand Down
28 changes: 5 additions & 23 deletions build-scripts/assemble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,40 +227,22 @@ function install_plugins() {
echo "Installing OpenSearch plugins"
local maven_repo_local="$HOME/.m2"

local PLUGIN_DIRECTORY=".m2/repository/org/opensearch/"
# If directory exists
if [ -d "$PLUGIN_DIRECTORY" ]; then
echo "Content of .m2/repository/org/opensearch/ pre-install plugins"
ls -la "$PLUGIN_DIRECTORY"
else
echo "Directory .m2/repository/org/opensearch/ doesn't exist"
fi

for plugin in "${plugins[@]}"; do
echo "Plugin ${plugin}, version ${VERSION}"
local plugin_from_maven="org.opensearch.plugin:${plugin}:${VERSION}.0"

if [[ -f "~/.m2/repository/org/opensearch/${plugin}/${VERSION}.0/${plugin}-${VERSION}.0.pom" ]]; then
echo "Plugin ${plugin} is already present, download omitted."
else
echo "Downloand ${plugin} plugin."
mvn -Dmaven.repo.local="${maven_repo_local}" org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=https://repo1.maven.org/maven2 -Dartifact="${plugin_from_maven}:zip"
OPENSEARCH_PATH_CONF=$PATH_CONF "${PATH_BIN}/opensearch-plugin" install --batch --verbose "file:${maven_repo_local}/org/opensearch/plugin/${plugin}/${VERSION}.0/${plugin}-${VERSION}.0.zip"
fi
echo "Download ${plugin} plugin."
mvn -Dmaven.repo.local="${maven_repo_local}" org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=https://repo1.maven.org/maven2 -Dartifact="${plugin_from_maven}:zip"
OPENSEARCH_PATH_CONF=$PATH_CONF "${PATH_BIN}/opensearch-plugin" install --batch --verbose "file:${maven_repo_local}/org/opensearch/plugin/${plugin}/${VERSION}.0/${plugin}-${VERSION}.0.zip"

done
if [ -d "$PLUGIN_DIRECTORY" ]; then
echo "Content of .m2/repository/org/opensearch/ post-install plugins of opensearch"
ls -la "$PLUGIN_DIRECTORY"
else
echo "Directory .m2/repository/org/opensearch/ doesn't exist post install"
fi

echo "Installing Wazuh plugins"
local indexer_plugin_version="${1}.${REVISION}"
for plugin_name in "${wazuh_plugins[@]}"; do
# Check if the plugin is in the local maven repository. This is usually
# case for local executions.
local plugin_path="${maven_repo_local}/repository/org/wazuh/${plugin_name}-plugin/${indexer_plugin_version}/${plugin_name}-${indexer_plugin_version}.zip"
local plugin_path="${maven_repo_local}/repository/com/wazuh/${plugin_name}-plugin/${indexer_plugin_version}/${plugin_name}-${indexer_plugin_version}.zip"

# Otherwise, search for the plugins in the output folder.
if [ -z "${plugin_from_maven_local}" ]; then
Expand Down

0 comments on commit cbd4cf0

Please sign in to comment.