Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/jenkins/TestRunGradleCheck.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ class TestRunGradleCheck extends BuildPipelineTest {
))
}

@Test
void testExcludeTasksInGradleCommand() {
runScript("tests/jenkins/jobs/RunGradleCheckExcludeTasks_Jenkinsfile")

def gradleCommands = getCommandExecutions('sh', 'gradle').findAll {
shCommand -> shCommand.contains('gradle')
}
assertThat(gradleCommands, hasItem(containsString("-x :plugins:repository-azure:check -x :plugins:repository-gcs:check")))
}

def getCommandExecutions(methodName, command) {
def shCommands = helper.callStack.findAll {
call ->
Expand Down
27 changes: 27 additions & 0 deletions tests/jenkins/jobs/RunGradleCheckExcludeTasks_Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

pipeline {
agent none
stages {
stage('gradle-check') {
steps {
script {
runGradleCheck(
gitRepoUrl: "https://github.com/opensearch-project/OpenSearch",
gitReference: "main",
bwcCheckoutAlign: "false",
scope: "server",
excludeTasks: ":plugins:repository-azure:check,:plugins:repository-gcs:check"
)
}
}
}
}
}
8 changes: 7 additions & 1 deletion vars/runGradleCheck.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @param args.gitReference <optional> - The git commit or branch that needs to be checked in OpenSearch repo to run check tasks defaults to main.
* @param args.bwcCheckoutAlign <optional> - Used to set the value of bwc.checkout.align, can be either true or false
* @param args.module_name <optional> - Defines module scope which has check tasks running and reported against it.
* @param args.excludeTasks <optional> - Comma-separated list of gradle tasks to exclude, e.g. ":plugins:repository-azure:check,:plugins:repository-gcs:check"
**/

void call(Map args = [:]) {
Expand All @@ -23,6 +24,7 @@ void call(Map args = [:]) {
def module_name = args.scope ?: 'null'
def bwc_checkout_align = args.bwcCheckoutAlign ?: 'false'
def bwc_checkout_align_param = ''
def exclude_tasks_param = ''
def command
println("Git Repo: ${git_repo_url}")
println("Git Reference: ${git_reference}")
Expand All @@ -33,6 +35,10 @@ void call(Map args = [:]) {
bwc_checkout_align_param = '-Dbwc.checkout.align=true'
}

if (args.excludeTasks) {
exclude_tasks_param = args.excludeTasks.split(',').collect { "-x ${it.trim()}" }.join(' ')
}

if (git_repo_url.equals('null') || git_reference.equals('null') || module_name.equals('null')) {
println("git repo url or git reference or module_name aren't specified to checkout the commit and run gradle check task, exit 1")
System.exit(1)
Expand Down Expand Up @@ -107,7 +113,7 @@ void call(Map args = [:]) {

echo "Start gradlecheck"
GRADLE_CHECK_STATUS=0
./gradlew clean && ./gradlew ${command} ${bwc_checkout_align_param} --no-daemon --no-scan || GRADLE_CHECK_STATUS=1
./gradlew clean && ./gradlew ${command} ${bwc_checkout_align_param} ${exclude_tasks_param} --no-daemon --no-scan || GRADLE_CHECK_STATUS=1

if [ "\$GRADLE_CHECK_STATUS" != 0 ]; then
echo Gradle Check Failed!
Expand Down
Loading