Skip to content

Commit

Permalink
Adding OSD in the distribution build pipeline with build script using…
Browse files Browse the repository at this point in the history
… volta to install nodejs dependencies (#2841)

* Adding OSD in the distribution build pipeline with build script using volta to install nodejs dependencies

Signed-off-by: Peter Zhu <[email protected]>
  • Loading branch information
peterzhuamazon authored Nov 3, 2022
1 parent 3eea73a commit 14693cc
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 28 deletions.
10 changes: 5 additions & 5 deletions jenkins/check-for-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ pipeline {
H 1 * * * %INPUT_MANIFEST=1.3.7/opensearch-dashboards-1.3.7.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux
H 1 * * * %INPUT_MANIFEST=1.4.0/opensearch-1.4.0.yml;TARGET_JOB_NAME=distribution-build-opensearch;BUILD_PLATFORM=linux macos
H 1 * * * %INPUT_MANIFEST=1.4.0/opensearch-dashboards-1.4.0.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux
H 1 * * * %INPUT_MANIFEST=2.3.1/opensearch-2.3.1.yml;TARGET_JOB_NAME=distribution-build-opensearch;BUILD_PLATFORM=linux macos
H 1 * * * %INPUT_MANIFEST=2.3.1/opensearch-dashboards-2.3.1.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux
H 1 * * * %INPUT_MANIFEST=2.3.1/opensearch-2.3.1.yml;TARGET_JOB_NAME=distribution-build-opensearch;BUILD_PLATFORM=linux macos windows
H 1 * * * %INPUT_MANIFEST=2.3.1/opensearch-dashboards-2.3.1.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux windows
H/60 * * * * %INPUT_MANIFEST=2.4.0/opensearch-2.4.0.yml;TARGET_JOB_NAME=distribution-build-opensearch;BUILD_PLATFORM=linux macos windows
H 1 * * * %INPUT_MANIFEST=2.4.0/opensearch-dashboards-2.4.0.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux
H 1 * * * %INPUT_MANIFEST=3.0.0/opensearch-3.0.0.yml;TARGET_JOB_NAME=distribution-build-opensearch;BUILD_PLATFORM=linux
H 1 * * * %INPUT_MANIFEST=3.0.0/opensearch-dashboards-3.0.0.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux
H/60 * * * * %INPUT_MANIFEST=2.4.0/opensearch-dashboards-2.4.0.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux windows
H 1 * * * %INPUT_MANIFEST=3.0.0/opensearch-3.0.0.yml;TARGET_JOB_NAME=distribution-build-opensearch;BUILD_PLATFORM=linux macos windows
H 1 * * * %INPUT_MANIFEST=3.0.0/opensearch-dashboards-3.0.0.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux windows
'''
}
parameters {
Expand Down
51 changes: 48 additions & 3 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ pipeline {
)
string( // Note: need to update 'verify-parameters' entries if you add new platform(s)
name: 'BUILD_PLATFORM',
description: "Build selected platform related artifacts, choices include 'linux'. Can combine multiple platforms with space in between",
defaultValue: 'linux',
description: "Build selected platform related artifacts, choices include 'linux windows'. Can combine multiple platforms with space in between",
defaultValue: 'linux windows',
trim: true
)
choice(
Expand Down Expand Up @@ -81,7 +81,7 @@ pipeline {
echo("Verify Build Platforms")
def build_platform_array = params.BUILD_PLATFORM.tokenize(' ')
echo("User Entry Platforms: '${params.BUILD_PLATFORM}', ${build_platform_array}")
def all_platforms = "linux"
def all_platforms = "linux windows"
echo("All Supported Platforms: '${all_platforms}'")

if (params.BUILD_PLATFORM == null || params.BUILD_PLATFORM == '') {
Expand Down Expand Up @@ -557,6 +557,50 @@ pipeline {
}
}
}
stage('build-and-test-windows-x64-zip') {
when {
beforeAgent true
expression{
params.BUILD_PLATFORM.contains('windows')
}
}
agent {
node {
label 'Jenkins-Agent-Windows2019-X64-C54xlarge-Single-Host'
}
}
steps {
script {
def buildManifestObj = buildAssembleUpload(
componentName: "${COMPONENT_NAME}",
inputManifest: "manifests/${INPUT_MANIFEST}",
platform: 'windows',
architecture: 'x64',
distribution: "zip"
)
String buildManifestUrl = buildManifestObj.getUrl(JOB_NAME, BUILD_NUMBER)
String artifactUrl = buildManifestObj.getArtifactUrl(JOB_NAME, BUILD_NUMBER)
env.ARTIFACT_URL_LINUX_WINDOWS_X64_ZIP = artifactUrl
env.INDEX_FILE_PATH = buildManifestObj.getIndexFileRoot("${JOB_NAME}")

echo "buildManifestUrl (windows, x64, zip): ${buildManifestUrl}"
echo "artifactUrl (windows, x64, zip): ${artifactUrl}"

}
}
post {
always {
script {
lib.jenkins.Messages.new(this).add(
"${STAGE_NAME}",
lib.jenkins.Messages.new(this).get(["${STAGE_NAME}"])
)

postCleanup()
}
}
}
}
}
}
stage('update index file') {
Expand Down Expand Up @@ -636,6 +680,7 @@ pipeline {
'assemble-archive-and-test-linux-x64-rpm',
'assemble-archive-and-test-linux-arm64-tar',
'assemble-archive-and-test-linux-arm64-rpm',
'build-and-test-windows-x64-zip'
])

publishNotification(
Expand Down
5 changes: 3 additions & 2 deletions jenkins/opensearch/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,8 @@ pipeline {
'build-and-test-linux-x64-tar',
'assemble-archive-and-test-linux-x64-rpm',
'build-and-test-linux-arm64-tar',
'assemble-archive-and-test-linux-arm64-rpm'
'assemble-archive-and-test-linux-arm64-rpm',
'build-and-test-windows-x64-zip'
])

publishNotification(
Expand Down Expand Up @@ -882,7 +883,7 @@ pipeline {
if (params.CREATE_GITHUB_ISSUE) {
createGithubIssue(
message: buildFailureMessage()
)
)
}

postCleanup()
Expand Down
3 changes: 2 additions & 1 deletion scripts/components/OpenSearch-Dashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ esac

NVM_CMD="source $NVM_DIR/nvm.sh && nvm use"
if [ "$PLATFORM" = "windows" ]; then
NVM_CMD="volta install node@`cat .nvmrc` && volta install yarn"
NVM_CMD="volta install node@`cat .nvmrc` && volta install yarn@`jq -r '.engines.yarn' package.json`"
fi

eval $NVM_CMD

echo "Building node modules for core with $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"
Expand Down
9 changes: 7 additions & 2 deletions scripts/components/customImportMapDashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,21 @@ fi
[ -z "$OUTPUT" ] && OUTPUT=artifacts
[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER"

NVM_CMD="source $NVM_DIR/nvm.sh && nvm use"
if [ "$PLATFORM" = "windows" ]; then
NVM_CMD="volta install node@`cat ../../../../OpenSearch-Dashboards/.nvmrc` && volta install yarn@`jq -r '.engines.yarn' ../../../../OpenSearch-Dashboards/package.json`"
fi

mkdir -p $OUTPUT/plugins
PLUGIN_FOLDER=$(basename "$PWD")
PLUGIN_NAME=customImportMapDashboards
# TODO: [CLEANUP] Needed OpenSearch Dashboards git repo to build the required modules for plugins
# This makes it so there is a dependency on having Dashboards pulled already.
cp -r ../$PLUGIN_FOLDER/ ../../../../OpenSearch-Dashboards/plugins
echo "BUILD MODULES FOR $PLUGIN_NAME"
(cd ../../../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap)
(cd ../../../../OpenSearch-Dashboards && eval $NVM_CMD && yarn osd bootstrap)
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
(cd ../../../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd plugins/$PLUGIN_FOLDER && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
(cd ../../../../OpenSearch-Dashboards && eval $NVM_CMD && cd plugins/$PLUGIN_FOLDER && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
echo "COPY $PLUGIN_NAME.zip"
cp -r ../../../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/
rm -rf ../../../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER
11 changes: 8 additions & 3 deletions scripts/components/ganttChartDashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ fi
[ -z "$OUTPUT" ] && OUTPUT=artifacts
[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER"

NVM_CMD="source $NVM_DIR/nvm.sh && nvm use"
if [ "$PLATFORM" = "windows" ]; then
NVM_CMD="volta install node@`cat ../../OpenSearch-Dashboards/.nvmrc` && volta install yarn@`jq -r '.engines.yarn' ../../OpenSearch-Dashboards/package.json`"
fi

mkdir -p $OUTPUT/plugins
# For hybrid plugin it actually resides in 'ganttChartDashboards/gantt-chart'
PLUGIN_FOLDER=$(basename "$PWD")
Expand All @@ -75,9 +80,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD"))
# This makes it so there is a dependency on having Dashboards pulled already.
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
echo "BUILD MODULES FOR $PLUGIN_NAME"
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap)
(cd ../../OpenSearch-Dashboards && eval $NVM_CMD && yarn osd bootstrap)
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd plugins/$PLUGIN_FOLDER && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
(cd ../../OpenSearch-Dashboards && eval $NVM_CMD && cd plugins/$PLUGIN_FOLDER && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
echo "COPY $PLUGIN_NAME.zip"
cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/
rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER
rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER
11 changes: 8 additions & 3 deletions scripts/components/notificationsDashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ fi
[ -z "$OUTPUT" ] && OUTPUT=artifacts
[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER"

NVM_CMD="source $NVM_DIR/nvm.sh && nvm use"
if [ "$PLATFORM" = "windows" ]; then
NVM_CMD="volta install node@`cat ../../OpenSearch-Dashboards/.nvmrc` && volta install yarn@`jq -r '.engines.yarn' ../../OpenSearch-Dashboards/package.json`"
fi

mkdir -p $OUTPUT/plugins
# For hybrid plugin it actually resides in 'queryWorkbenchDashboards/workbench'
PLUGIN_FOLDER=$(basename "$PWD")
Expand All @@ -75,9 +80,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD"))
# This makes it so there is a dependency on having Dashboards pulled already.
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
echo "BUILD MODULES FOR $PLUGIN_NAME"
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap)
(cd ../../OpenSearch-Dashboards && eval $NVM_CMD && yarn osd bootstrap)
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
(cd ../../OpenSearch-Dashboards && eval $NVM_CMD && cd plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
echo "COPY $PLUGIN_NAME.zip"
cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/
rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER
rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER
9 changes: 7 additions & 2 deletions scripts/components/observabilityDashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ fi
[ -z "$OUTPUT" ] && OUTPUT=artifacts
[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER"

NVM_CMD="source $NVM_DIR/nvm.sh && nvm use"
if [ "$PLATFORM" = "windows" ]; then
NVM_CMD="volta install node@`cat ../../OpenSearch-Dashboards/.nvmrc` && volta install yarn@`jq -r '.engines.yarn' ../../OpenSearch-Dashboards/package.json`"
fi

mkdir -p $OUTPUT/plugins
# For hybrid plugin it actually resides in 'observability/dashboards-observability'
PLUGIN_FOLDER=$(basename "$PWD")
Expand All @@ -75,9 +80,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD"))
# This makes it so there is a dependency on having Dashboards pulled already.
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
echo "BUILD MODULES FOR $PLUGIN_NAME"
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap)
(cd ../../OpenSearch-Dashboards && eval $NVM_CMD && yarn osd bootstrap)
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
(cd ../../OpenSearch-Dashboards && eval $NVM_CMD && cd plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
echo "COPY $PLUGIN_NAME.zip"
cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/
rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER
11 changes: 8 additions & 3 deletions scripts/components/queryWorkbenchDashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ fi
[ -z "$OUTPUT" ] && OUTPUT=artifacts
[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER"

NVM_CMD="source $NVM_DIR/nvm.sh && nvm use"
if [ "$PLATFORM" = "windows" ]; then
NVM_CMD="volta install node@`cat ../../OpenSearch-Dashboards/.nvmrc` && volta install yarn@`jq -r '.engines.yarn' ../../OpenSearch-Dashboards/package.json`"
fi

mkdir -p $OUTPUT/plugins
# For hybrid plugin it actually resides in 'queryWorkbenchDashboards/workbench'
PLUGIN_FOLDER=$(basename "$PWD")
Expand All @@ -75,9 +80,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD"))
# This makes it so there is a dependency on having Dashboards pulled already.
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
echo "BUILD MODULES FOR $PLUGIN_NAME"
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap)
(cd ../../OpenSearch-Dashboards && eval $NVM_CMD && yarn osd bootstrap)
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
(cd ../../OpenSearch-Dashboards && eval $NVM_CMD && cd plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
echo "COPY $PLUGIN_NAME.zip"
cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/
rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER
rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER
2 changes: 1 addition & 1 deletion scripts/components/reportsDashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ esac

NVM_CMD="source $NVM_DIR/nvm.sh && nvm use"
if [ "$PLATFORM" = "windows" ]; then
NVM_CMD="volta install node@`cat ../../OpenSearch-Dashboards/.nvmrc` && volta install yarn"
NVM_CMD="volta install node@`cat ../../OpenSearch-Dashboards/.nvmrc` && volta install yarn@`jq -r '.engines.yarn' ../../OpenSearch-Dashboards/package.json`"
fi

CHROMIUM_URL="https://github.com/opensearch-project/dashboards-reports/releases/download/chromium-1.12.0.0/$CHROMIUM_TARGET"
Expand Down
11 changes: 8 additions & 3 deletions scripts/default/opensearch-dashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,20 @@ fi
[ -z "$OUTPUT" ] && OUTPUT=artifacts
[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER"

NVM_CMD="source $NVM_DIR/nvm.sh && nvm use"
if [ "$PLATFORM" = "windows" ]; then
NVM_CMD="volta install node@`cat ../OpenSearch-Dashboards/.nvmrc` && volta install yarn@`jq -r '.engines.yarn' ../OpenSearch-Dashboards/package.json`"
fi

mkdir -p $OUTPUT/plugins
PLUGIN_NAME=$(basename "$PWD")
# TODO: [CLEANUP] Needed OpenSearch Dashboards git repo to build the required modules for plugins
# This makes it so there is a dependency on having Dashboards pulled already.
cp -r ../$PLUGIN_NAME/ ../OpenSearch-Dashboards/plugins
echo "BUILD MODULES FOR $PLUGIN_NAME"
(cd ../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap)
(cd ../OpenSearch-Dashboards && eval $NVM_CMD && yarn osd bootstrap)
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
(cd ../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd plugins/$PLUGIN_NAME && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
(cd ../OpenSearch-Dashboards && eval $NVM_CMD && cd plugins/$PLUGIN_NAME && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
echo "COPY $PLUGIN_NAME.zip"
cp -r ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/
rm -rf ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME
rm -rf ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME

0 comments on commit 14693cc

Please sign in to comment.