Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add windows gradle check agent params #2840

Closed
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
201 changes: 112 additions & 89 deletions jenkins/gradle/gradle-check.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ lib = library(identifier: '[email protected]', retriever: modernSCM([
]))

pipeline {
agent none
options {
timeout(time: 2, unit: 'HOURS')
throttleJobProperty(
Expand All @@ -16,16 +17,6 @@ pipeline {
throttleOption: 'project',
)
}
// gradle check have a lot of issues running on containers
// Therefore, we directly run it on the agent node
agent {
node {
// Must use Ubuntu agent with 1 executor or gradle check will show a lot of java-related errors
// The c524xlarge is the instance type that has the least amount of errors during gradle check
// https://github.com/opensearch-project/OpenSearch/issues/1975
label 'Jenkins-Agent-Ubuntu2004-X64-C524xlarge-Single-Host'
}
}
parameters {
string(
name: 'GIT_REPO_URL',
Expand All @@ -39,6 +30,14 @@ pipeline {
defaultValue: 'main',
trim: true
)
// Must use agent with 1 executor or gradle check will show a lot of java-related errors
// The c524xlarge is the instance type that has the least amount of errors during gradle check
// https://github.com/opensearch-project/OpenSearch/issues/1975
choice(
name: 'AGENT_LABEL',
description: 'Choose which jenkins agent to run gradle check on',
choices: ['Jenkins-Agent-Ubuntu2004-X64-C524xlarge-Single-Host', 'Jenkins-Agent-Windows2019-X64-C524xlarge-Single-Host'],
)
}
triggers {
GenericTrigger(
Expand All @@ -65,93 +64,117 @@ pipeline {
TIMER_BUILD_CAUSE = currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause')
}
stages {
stage('Install openjdk-8') {
tools {
jdk 'openjdk-8'
}
steps {
echo "Install openjdk-8"
sh("ls ${JAVA8_HOME}/.. | grep openjdk-8")
}
}
stage('Install openjdk-11') {
tools {
jdk 'openjdk-11'
}
steps {
echo "Install openjdk-11"
sh("ls ${JAVA11_HOME}/.. | grep openjdk-11")
}
}
stage('Install openjdk-14') {
tools {
jdk 'openjdk-14'
}
steps {
echo "Install openjdk-14"
sh("ls ${JAVA14_HOME}/.. | grep openjdk-14")
}
}
stage('Install openjdk-17') {
tools {
jdk 'openjdk-17'
}
steps {
echo "Install openjdk-17"
sh("ls ${JAVA17_HOME}/.. | grep openjdk-17")
stage('verify-parameters') {
agent {
docker {
label 'Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host'
image 'alpine:3'
alwaysPull true
}
}
}
stage('Install openjdk-19') {
tools {
jdk 'openjdk-19'
}
steps {
echo "Install openjdk-19"
sh("ls ${JAVA19_HOME}/.. | grep openjdk-19")
script {
if (AGENT_LABEL == '') {
currentBuild.result = 'ABORTED'
error("Gradle Check (Jenkins) failed to start. Missing parameter: AGENT_LABEL.")
}
}
}
}
stage('Run Gradle Check') {
steps {
script {
sh("ls /var/jenkins/tools/hudson.model.JDK/")
if (env.USER_BUILD_CAUSE.equals('[]') && env.TIMER_BUILD_CAUSE.equals('[]')) {
def pr_url = "${pr_to_clone_url}".replace(".git", "/pull/${pr_number}")
println("Triggered by GitHub: ${pr_to_clone_url}")
if ("$pr_number" == "Null") {
currentBuild.description = """<a href="${pr_to_clone_url}">Others</a>: ${pr_title}"""
}
else {
currentBuild.description = """<a href="${pr_url}">PR #${pr_number}</a>: ${pr_title}"""
}

runGradleCheck(
gitRepoUrl: "${pr_from_clone_url}",
gitReference: "${pr_from_sha}"
)
stage('Gradle Check') {
// gradle check have a lot of issues running on containers
// Therefore, we directly run it on the agent node
agent { label AGENT_LABEL }
stages {
stage('Install openjdk-8') {
tools {
jdk 'openjdk-8'
}
else {
println("Triggered by User or Triggered by Timer")
def repo_url = "${GIT_REPO_URL}".replace(".git", "/commit")
currentBuild.description = """git: <a href="${GIT_REPO_URL}">${GIT_REPO_URL}</a><br>ref: <a href="${repo_url}/${GIT_REFERENCE}">${GIT_REFERENCE}</a>"""

runGradleCheck(
gitRepoUrl: "${GIT_REPO_URL}",
gitReference: "${GIT_REFERENCE}"
)
steps {
echo "Install openjdk-8"
sh("ls ${JAVA8_HOME}/.. | grep openjdk-8")
}
}
}
post() {
failure {
archiveArtifacts artifacts: '**/build/heapdump/*.hprof', allowEmptyArchive: true
stage('Install openjdk-11') {
tools {
jdk 'openjdk-11'
}
steps {
echo "Install openjdk-11"
sh("ls ${JAVA11_HOME}/.. | grep openjdk-11")
}
}
always {
sh ("cp -v `find search/build/reports/jacoco/ -name '*.xml' | head -n 1` codeCoverage.xml || echo")
junit allowEmptyResults: true, testResults: '**/build/test-results/**/*.xml'
archiveArtifacts artifacts: 'codeCoverage.xml', onlyIfSuccessful: true
script {
sh("rm -rf *")
postCleanup()
stage('Install openjdk-14') {
tools {
jdk 'openjdk-14'
}
steps {
echo "Install openjdk-14"
sh("ls ${JAVA14_HOME}/.. | grep openjdk-14")
}
}
stage('Install openjdk-17') {
tools {
jdk 'openjdk-17'
}
steps {
echo "Install openjdk-17"
sh("ls ${JAVA17_HOME}/.. | grep openjdk-17")
}
}
stage('Install openjdk-19') {
tools {
jdk 'openjdk-19'
}
steps {
echo "Install openjdk-19"
sh("ls ${JAVA19_HOME}/.. | grep openjdk-19")
}
}
stage('Run Gradle Check') {
steps {
script {
sh("ls /var/jenkins/tools/hudson.model.JDK/")
if (env.USER_BUILD_CAUSE.equals('[]') && env.TIMER_BUILD_CAUSE.equals('[]')) {
def pr_url = "${pr_to_clone_url}".replace(".git", "/pull/${pr_number}")
println("Triggered by GitHub: ${pr_to_clone_url}")
if ("$pr_number" == "Null") {
currentBuild.description = """<a href="${pr_to_clone_url}">Others</a>: ${pr_title}"""
}
else {
currentBuild.description = """<a href="${pr_url}">PR #${pr_number}</a>: ${pr_title}"""
}

runGradleCheck(
gitRepoUrl: "${pr_from_clone_url}",
gitReference: "${pr_from_sha}"
)
}
else {
println("Triggered by User or Triggered by Timer")
def repo_url = "${GIT_REPO_URL}".replace(".git", "/commit")
currentBuild.description = """git: <a href="${GIT_REPO_URL}">${GIT_REPO_URL}</a><br>ref: <a href="${repo_url}/${GIT_REFERENCE}">${GIT_REFERENCE}</a>"""

runGradleCheck(
gitRepoUrl: "${GIT_REPO_URL}",
gitReference: "${GIT_REFERENCE}"
)
}
}
}
post() {
failure {
archiveArtifacts artifacts: '**/build/heapdump/*.hprof', allowEmptyArchive: true
}
always {
sh ("cp -v `find search/build/reports/jacoco/ -name '*.xml' | head -n 1` codeCoverage.xml || echo")
junit allowEmptyResults: true, testResults: '**/build/test-results/**/*.xml'
archiveArtifacts artifacts: 'codeCoverage.xml', onlyIfSuccessful: true
script {
sh("rm -rf *")
postCleanup()
}
}
}
}
}
Expand Down
Binary file not shown.