Skip to content

Commit

Permalink
Add distribution selector for distribution builds on Jenkins (#3149)
Browse files Browse the repository at this point in the history
* Add distribution selector for distribution builds on Jenkins

Signed-off-by: Peter Zhu <[email protected]>

* Add check for build entry to python lib

Signed-off-by: Peter Zhu <[email protected]>

* Add check for build entry to python lib

Signed-off-by: Peter Zhu <[email protected]>

---------

Signed-off-by: Peter Zhu <[email protected]>
  • Loading branch information
peterzhuamazon authored Jan 27, 2023
1 parent 303e08a commit 7506194
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 68 deletions.
22 changes: 14 additions & 8 deletions jenkins/check-for-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ pipeline {
}
triggers {
parameterizedCron '''
H 1 * * * %INPUT_MANIFEST=2.6.0/opensearch-2.6.0.yml;TARGET_JOB_NAME=distribution-build-opensearch;BUILD_PLATFORM=linux windows
H 1 * * * %INPUT_MANIFEST=2.6.0/opensearch-dashboards-2.6.0.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux windows
H 1 * * * %INPUT_MANIFEST=2.4.2/opensearch-dashboards-2.4.2.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux windows
H 1 * * * %INPUT_MANIFEST=2.4.2/opensearch-2.4.2.yml;TARGET_JOB_NAME=distribution-build-opensearch;BUILD_PLATFORM=linux macos windows
H 1 * * * %INPUT_MANIFEST=1.4.0/opensearch-1.4.0.yml;TARGET_JOB_NAME=distribution-build-opensearch;BUILD_PLATFORM=linux macos windows
H 1 * * * %INPUT_MANIFEST=1.4.0/opensearch-dashboards-1.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
H 1 * * * %INPUT_MANIFEST=2.6.0/opensearch-2.6.0.yml;TARGET_JOB_NAME=distribution-build-opensearch;BUILD_PLATFORM=linux windows;BUILD_DISTRIBUTION=tar rpm deb zip
H 1 * * * %INPUT_MANIFEST=2.6.0/opensearch-dashboards-2.6.0.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux windows;BUILD_DISTRIBUTION=tar rpm deb zip
H 1 * * * %INPUT_MANIFEST=2.4.2/opensearch-dashboards-2.4.2.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux windows;BUILD_DISTRIBUTION=tar rpm deb zip
H 1 * * * %INPUT_MANIFEST=2.4.2/opensearch-2.4.2.yml;TARGET_JOB_NAME=distribution-build-opensearch;BUILD_PLATFORM=linux macos windows;BUILD_DISTRIBUTION=tar rpm deb zip
H 1 * * * %INPUT_MANIFEST=1.4.0/opensearch-1.4.0.yml;TARGET_JOB_NAME=distribution-build-opensearch;BUILD_PLATFORM=linux macos windows;BUILD_DISTRIBUTION=tar rpm zip
H 1 * * * %INPUT_MANIFEST=1.4.0/opensearch-dashboards-1.4.0.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux windows;BUILD_DISTRIBUTION=tar rpm zip
H 1 * * * %INPUT_MANIFEST=3.0.0/opensearch-3.0.0.yml;TARGET_JOB_NAME=distribution-build-opensearch;BUILD_PLATFORM=linux macos windows;BUILD_DISTRIBUTION=tar rpm deb zip
H 1 * * * %INPUT_MANIFEST=3.0.0/opensearch-dashboards-3.0.0.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards;BUILD_PLATFORM=linux windows;BUILD_DISTRIBUTION=tar rpm deb zip
'''
}
parameters {
Expand All @@ -45,6 +45,11 @@ pipeline {
description: 'Platform to build',
trim: true
)
string(
name: 'BUILD_DISTRIBUTION',
description: 'Distribution to build',
trim: true
)
}
stages {
stage('detect docker image + args') {
Expand Down Expand Up @@ -88,6 +93,7 @@ pipeline {
string(name: 'INPUT_MANIFEST', value: "${INPUT_MANIFEST}"),
string(name: 'TEST_MANIFEST', value: "${TEST_MANIFEST}"),
string(name: 'BUILD_PLATFORM', value: "${BUILD_PLATFORM}")
string(name: 'BUILD_DISTRIBUTION', value: "${BUILD_DISTRIBUTION}")
], wait: true

echo "Build succeeded, uploading build SHA for that job"
Expand Down
119 changes: 95 additions & 24 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@ 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 windows'. Can combine multiple platforms with space in between",
description: "Build selected platform related artifacts, choices include 'linux windows'. Can combine multiple platforms with space in between (docker is only available on linux)",
defaultValue: 'linux windows',
trim: true
)
string( // Note: need to update 'verify-parameters' entries if you add new distribution(s)
name: 'BUILD_DISTRIBUTION',
description: "Build selected distribution related artifacts, choices include 'tar', 'rpm', 'deb', 'zip'. Can combine multiple distributions with space in between (docker is only available on tar)",
defaultValue: 'tar rpm deb zip',
trim: true
)
choice(
name: 'BUILD_DOCKER',
description: 'Build docker image or not with options.',
Expand Down Expand Up @@ -101,6 +107,25 @@ pipeline {
error("Missing parameter: BUILD_PLATFORM (possible entries: ${all_platforms}).")
}
}

echo("Verify Build Distributions")
def build_distribution_array = params.BUILD_DISTRIBUTION.tokenize(' ')
echo("User Entry Distributions: '${params.BUILD_DISTRIBUTION}', ${build_distribution_array}")
def all_distributions = "tar rpm deb zip"
echo("All Supported Platforms: '${all_distributions}'")

if (params.BUILD_DISTRIBUTION == null || params.BUILD_DISTRIBUTION == '') {
currentBuild.result = 'ABORTED'
error("Missing parameter: BUILD_DISTRIBUTION (possible entries: ${all_distributions}).")
}

for (String plat : build_distribution_array) {
if (! all_distributions.contains(plat)) {
currentBuild.result = 'ABORTED'
error("Missing parameter: BUILD_DISTRIBUTION (possible entries: ${all_distributions}).")
}
}

}
}
}
Expand Down Expand Up @@ -133,8 +158,13 @@ pipeline {
stage('build-and-test-linux-x64-tar') {
when {
beforeAgent true
expression{
params.BUILD_PLATFORM.contains('linux')
allOf{
expression {
params.BUILD_PLATFORM.contains('linux')
}
expression{
params.BUILD_DISTRIBUTION.contains('tar')
}
}
}
agent {
Expand Down Expand Up @@ -237,8 +267,13 @@ pipeline {
stage('build-and-test-linux-x64-rpm') {
when {
beforeAgent true
expression{
params.BUILD_PLATFORM.contains('linux')
allOf{
expression {
params.BUILD_PLATFORM.contains('linux')
}
expression{
params.BUILD_DISTRIBUTION.contains('rpm')
}
}
}
agent { label AGENT_X64 }
Expand Down Expand Up @@ -332,8 +367,13 @@ pipeline {
stage('build-and-test-linux-x64-deb') {
when {
beforeAgent true
expression{
params.BUILD_PLATFORM.contains('linux')
allOf{
expression {
params.BUILD_PLATFORM.contains('linux')
}
expression{
params.BUILD_DISTRIBUTION.contains('deb')
}
}
}
agent { label AGENT_X64 }
Expand Down Expand Up @@ -412,8 +452,13 @@ pipeline {
stage('build-and-test-linux-arm64-tar') {
when {
beforeAgent true
expression{
params.BUILD_PLATFORM.contains('linux')
allOf{
expression {
params.BUILD_PLATFORM.contains('linux')
}
expression{
params.BUILD_DISTRIBUTION.contains('tar')
}
}
}
agent { label AGENT_X64 }
Expand Down Expand Up @@ -554,8 +599,13 @@ pipeline {
stage('build-and-test-linux-arm64-rpm') {
when {
beforeAgent true
expression{
params.BUILD_PLATFORM.contains('linux')
allOf{
expression {
params.BUILD_PLATFORM.contains('linux')
}
expression{
params.BUILD_DISTRIBUTION.contains('rpm')
}
}
}
agent { label AGENT_X64 }
Expand Down Expand Up @@ -654,8 +704,13 @@ pipeline {
stage('build-and-test-linux-arm64-deb') {
when {
beforeAgent true
expression{
params.BUILD_PLATFORM.contains('linux')
allOf{
expression {
params.BUILD_PLATFORM.contains('linux')
}
expression{
params.BUILD_DISTRIBUTION.contains('deb')
}
}
}
agent { label AGENT_ARM64 }
Expand Down Expand Up @@ -734,8 +789,13 @@ pipeline {
stage('build-and-test-windows-x64-zip') {
when {
beforeAgent true
expression{
params.BUILD_PLATFORM.contains('windows')
allOf{
expression {
params.BUILD_PLATFORM.contains('windows')
}
expression{
params.BUILD_DISTRIBUTION.contains('zip')
}
}
}
agent {
Expand Down Expand Up @@ -805,6 +865,9 @@ pipeline {
expression{
params.BUILD_PLATFORM.contains('linux')
}
expression{
params.BUILD_DISTRIBUTION.contains('tar')
}
}
}
agent {
Expand Down Expand Up @@ -851,17 +914,25 @@ pipeline {
script {
List<String> stages = []
if (params.BUILD_PLATFORM.contains('linux')) {
stages = [
'build-and-test-linux-x64-tar',
'assemble-archive-and-test-linux-x64-rpm',
'assemble-archive-and-test-linux-x64-deb',
'assemble-archive-and-test-linux-arm64-tar',
'assemble-archive-and-test-linux-arm64-rpm',
'assemble-archive-and-test-linux-arm64-deb',
]
if (params.BUILD_DISTRIBUTION.contains('tar')) {
stages = [
'build-and-test-linux-x64-tar',
'assemble-archive-and-test-linux-arm64-tar',
]
}
if (params.BUILD_DISTRIBUTION.contains('rpm')) {
stages.add('assemble-archive-and-test-linux-x64-rpm')
stages.add('assemble-archive-and-test-linux-arm64-rpm')
}
if (params.BUILD_DISTRIBUTION.contains('deb')) {
stages.add('assemble-archive-and-test-linux-x64-deb')
stages.add('assemble-archive-and-test-linux-arm64-deb')
}
}
if (params.BUILD_PLATFORM.contains('windows')){
stages.add('build-and-test-windows-x64-zip')
if (params.BUILD_DISTRIBUTION.contains('zip')) {
stages.add('build-and-test-windows-x64-zip')
}
}
if (params.PUBLISH_NOTIFICATION) {
def stashed = lib.jenkins.Messages.new(this).get(stages)
Expand Down
Loading

0 comments on commit 7506194

Please sign in to comment.