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

feat: add support for jenkins-helper git ref when build pipeline #420

Closed
wants to merge 4 commits into from
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
4 changes: 3 additions & 1 deletion docs/UsingOurScripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ This file contains the default constants and paths used in the build scripts for
// Git Url of the current repository.
"pipeline_url" : "https://github.com/adoptium/ci-jenkins-pipelines.git",
// Git branch you wish to use when running the groovy scripts inside the pipeline_url
"pipeline_branch" : "master"
"pipeline_branch" : "master",
// Git branch of which checkout from https://github.com/adoptium/jenkins-helper.git repo. This can only be as branch or tag, not SHA1
"helper_ref" : "master"
},
// Jenkins server details
"jenkinsDetails" : {
Expand Down
6 changes: 4 additions & 2 deletions pipelines/build/common/build_base_file.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class Builder implements Serializable {
IndividualBuildConfig buildConfiguration(Map<String, ?> platformConfig, String variant) {

// Query the Adopt api to get the "tip_version"
def JobHelper = context.library(identifier: 'openjdk-jenkins-helper@master').JobHelper
String helperRef = DEFAULTS_JSON['repository']['helper_ref']
def JobHelper = context.library(identifier: "openjdk-jenkins-helper@${helperRef}").JobHelper
context.println "Querying Adopt Api for the JDK-Head number (tip_version)..."
def response = JobHelper.getAvailableReleases(context)
int headVersion = (int) response.getAt("tip_version")
Expand Down Expand Up @@ -632,7 +633,8 @@ class Builder implements Serializable {
try {
context.timeout(time: pipelineTimeouts.API_REQUEST_TIMEOUT, unit: "HOURS") {
// Query the Adopt api to get the "tip_version"
def JobHelper = context.library(identifier: 'openjdk-jenkins-helper@master').JobHelper
String helperRef = DEFAULTS_JSON['repository']['helper_ref']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably needs to check if helper_ref is blank or not set? then default to master?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or can we assume DEFAULTS_JSON must set it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so i added it to the pipeline/defaults.json to master as the default value.
see test : https://ci.adoptopenjdk.net/job/build-scripts-pr-tester/job/build-test/job/openjdk11-pipeline/930/parameters/

def JobHelper = context.library(identifier: "openjdk-jenkins-helper@${helperRef}").JobHelper
context.println "Querying Adopt Api for the JDK-Head number (tip_version)..."
def response = JobHelper.getAvailableReleases(context)
return (int) response.getAt("tip_version")
Expand Down
4 changes: 3 additions & 1 deletion pipelines/build/common/config_regeneration.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,9 @@ class Regeneration implements Serializable {
// If we're building jdk head, update the javaToBuild
context.println "[INFO] Querying Adoptium api to get the JDK-Head number"

def JobHelper = context.library(identifier: 'openjdk-jenkins-helper@master').JobHelper
String helperRef = DEFAULTS_JSON['repository']['helper_ref']
def JobHelper = context.library(identifier: "openjdk-jenkins-helper@${helperRef}").JobHelper

Integer jdkHeadNum = Integer.valueOf(JobHelper.getAvailableReleases(context).tip_version)

if (Integer.valueOf(versionNumbers[0]) == jdkHeadNum) {
Expand Down
3 changes: 2 additions & 1 deletion pipelines/build/common/kick_off_build.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ node("worker") {
userRemoteConfigs = new JsonSlurper().parseText(USER_REMOTE_CONFIGS) as Map
}

library(identifier: 'openjdk-jenkins-helper@master')
String helperRef = LOCAL_DEFAULTS_JSON['repository']['helper_ref']
library(identifier: "openjdk-jenkins-helper@${helperRef}")

try {
downstreamBuilder = load "${WORKSPACE}/${baseFilePath}"
Expand Down
15 changes: 10 additions & 5 deletions pipelines/build/common/openjdk_build_pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ class Build {
try {
context.timeout(time: buildTimeouts.API_REQUEST_TIMEOUT, unit: "HOURS") {
// Query the Adopt api to get the "tip_version"
def JobHelper = context.library(identifier: 'openjdk-jenkins-helper@master').JobHelper
String helperRef = DEFAULTS_JSON['repository']['helper_ref']
def JobHelper = context.library(identifier: "openjdk-jenkins-helper@${helperRef}").JobHelper
context.println "Querying Adopt Api for the JDK-Head number (tip_version)..."

def response = JobHelper.getAvailableReleases(context)
Expand Down Expand Up @@ -289,7 +290,8 @@ class Build {
context.stage("smoke test") {
def jobParams = getSmokeTestJobParams()
def jobName = jobParams.TEST_JOB_NAME
def JobHelper = context.library(identifier: 'openjdk-jenkins-helper@master').JobHelper
String helperRef = DEFAULTS_JSON['repository']['helper_ref']
def JobHelper = context.library(identifier: "openjdk-jenkins-helper@${helperRef}").JobHelper
if (!JobHelper.jobIsRunnable(jobName as String)) {
context.node('worker') {
context.sh('curl -Os https://raw.githubusercontent.com/adoptium/aqa-tests/master/buildenv/jenkins/testJobTemplate')
Expand Down Expand Up @@ -380,7 +382,8 @@ class Build {
}

def jobName = jobParams.TEST_JOB_NAME
def JobHelper = context.library(identifier: 'openjdk-jenkins-helper@master').JobHelper
String helperRef = DEFAULTS_JSON['repository']['helper_ref']
def JobHelper = context.library(identifier: "openjdk-jenkins-helper@${helperRef}").JobHelper

// Create test job if AQA_AUTO_GEN is set to true, the job doesn't exist or is not runnable
if (aqaAutoGen || !JobHelper.jobIsRunnable(jobName as String)) {
Expand Down Expand Up @@ -1484,7 +1487,8 @@ class Build {
If it doesn't find one or the timeout is set to 0 (default), it'll crash out. Otherwise, it'll return and jump onto the node.
*/
def waitForANodeToBecomeActive(def label) {
def NodeHelper = context.library(identifier: 'openjdk-jenkins-helper@master').NodeHelper
String helperRef = DEFAULTS_JSON['repository']['helper_ref']
def NodeHelper = context.library(identifier: "openjdk-jenkins-helper@${helperRef}").NodeHelper

// A node with the requested label is ready to go
if (NodeHelper.nodeIsOnline(label)) {
Expand Down Expand Up @@ -1574,7 +1578,8 @@ class Build {
context.stage("queue") {
/* This loads the library containing two Helper classes, and causes them to be
imported/updated from their repo. Without the library being imported here, runTests method will fail to execute the post-build test jobs for reasons unknown.*/
context.library(identifier: 'openjdk-jenkins-helper@master')
String helperRef = DEFAULTS_JSON['repository']['helper_ref']
context.library(identifier: "openjdk-jenkins-helper@${helperRef}")

// Set Github Commit Status
if (env.JOB_NAME.contains("pr-tester")) {
Expand Down
3 changes: 2 additions & 1 deletion pipelines/build/openjdk_pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ node ("worker") {

scmVars = checkout scm

library(identifier: 'openjdk-jenkins-helper@master')
String helperRef = DEFAULTS_JSON['repository']['helper_ref']
library(identifier: "openjdk-jenkins-helper@${helperRef}")

// Load baseFilePath. This is where build_base_file.groovy is located. It runs the downstream job setup and configuration retrieval services.
def baseFilePath = (params.baseFilePath) ?: DEFAULTS_JSON['baseFileDirectories']['upstream']
Expand Down
4 changes: 3 additions & 1 deletion pipelines/build/prTester/kick_off_tester.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if (!DEFAULTS_JSON) {
}

String url = DEFAULTS_JSON['repository']['pipeline_url']
String helperRef = DEFAULTS_JSON['repository']['helper_ref']
Closure prTest

// Switch to controller node to load library groovy definitions
Expand All @@ -39,7 +40,8 @@ node("worker") {
]]
])

library(identifier: 'openjdk-jenkins-helper@master')

library(identifier: "openjdk-jenkins-helper@${helperRef}")
prTest = load DEFAULTS_JSON['scriptDirectories']['tester']
}

Expand Down
3 changes: 2 additions & 1 deletion pipelines/build/regeneration/build_job_generator.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ node ("worker") {

checkoutUserPipelines()

library(identifier: 'openjdk-jenkins-helper@master')
String helperRef = DEFAULTS_JSON['repository']['helper_ref']
library(identifier: "openjdk-jenkins-helper@${helperRef}")

// Load buildConfigurations from config file. This is what the nightlies & releases use to setup their downstream jobs
def buildConfigurations = null
Expand Down
7 changes: 5 additions & 2 deletions pipelines/build/regeneration/build_pipeline_generator.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ node('worker') {

// Checkout into user repository
checkoutUserPipelines()

String helperRef = DEFAULTS_JSON['repository']['helper_ref']
library(identifier: "openjdk-jenkins-helper@${helperRef}")

library(identifier: 'openjdk-jenkins-helper@master')

// Load jobRoot. This is where the openjdkxx-pipeline jobs will be created.
def jobRoot = (params.JOB_ROOT) ?: DEFAULTS_JSON["jenkinsDetails"]["rootDirectory"]
Expand Down Expand Up @@ -134,7 +136,8 @@ node('worker') {
println "USE_ADOPT_SHELL_SCRIPTS = $useAdoptShellScripts"

// Collect available JDK versions to check for generation (tip_version + 1 just in case it is out of date on a release day)
def JobHelper = library(identifier: 'openjdk-jenkins-helper@master').JobHelper

def JobHelper = library(identifier: "openjdk-jenkins-helper@${helperRef}").JobHelper
println "Querying Adopt Api for the JDK-Head number (tip_version)..."

def response = JobHelper.getAvailableReleases(this)
Expand Down
3 changes: 2 additions & 1 deletion pipelines/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"build_branch" : "master",
"test_dirs" : "/test/functional",
"pipeline_url" : "https://github.com/adoptium/ci-jenkins-pipelines.git",
"pipeline_branch" : "master"
"pipeline_branch" : "master",
"helper_ref" : "master"
},
"jenkinsDetails" : {
"rootUrl" : "https://ci.adoptopenjdk.net",
Expand Down
6 changes: 3 additions & 3 deletions pipelines/jobs/pipeline_job_template.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ pipelineJob("${BUILD_FOLDER}/${JOB_NAME}") {
parameters {
textParam('targetConfigurations', JsonOutput.prettyPrint(JsonOutput.toJson(targetConfigurations)))
stringParam('activeNodeTimeout', "0", 'Number of minutes we will wait for a label-matching node to become active.')
stringParam('jdkVersion', jdkVersion, 'The JDK version of the pipeline e.g (11, 8, 17).')
stringParam('jdkVersion', jdkVersion, 'The JDK version of the pipeline e.g (8, 11, 17, 19, 20).')
stringParam('dockerExcludes', "", 'Map of targetConfigurations to exclude from docker building. If a targetConfiguration (i.e. { "x64LinuxXL": [ "openj9" ], "aarch64Linux": [ "hotspot", "openj9" ] }) has been entered into this field, jenkins will build the jdk without using docker. This param overrides the dockerImage and dockerFile downstream job parameters.')
stringParam('baseFilePath', "", "Relative path to where the build_base_file.groovy file is located. This runs the downstream job setup and configuration retrieval services.<br>Default: <code>${defaultsJson['baseFileDirectories']['upstream']}</code>")
stringParam('buildConfigFilePath', "", "Relative path to where the jdkxx_pipeline_config.groovy file is located. It contains the build configurations for each platform, architecture and variant.<br>Default: <code>${defaultsJson['configDirectories']['build']}/jdkxx_pipeline_config.groovy</code>")
choiceParam('releaseType', ['Nightly', 'Nightly Without Publish', 'Weekly', 'Release'], 'Nightly - release a standard nightly build.<br/>Nightly Without Publish - run a nightly but do not publish.<br/>Weekly - release a standard weekly build, run with extended tests.<br/>Release - this is a release, this will need to be manually promoted.')
stringParam('overridePublishName', "", '<strong>REQUIRED for OpenJ9</strong>: Name that determines the publish name (and is used by the meta-data file), defaults to scmReference(minus _adopt if present).<br/>Nightly builds: Leave blank (defaults to a date_time stamp).<br/>OpenJ9 Release build Java 8 example <code>jdk8u192-b12_openj9-0.12.1</code> and for OpenJ9 Java 11 example <code>jdk-11.0.2+9_openj9-0.12.1</code>.')
stringParam('scmReference', "", 'Tag name or Branch name from which to build. Nightly builds: Defaults to, Hotspot=dev, OpenJ9=openj9, others=master.</br>Release builds: For hotspot JDK8 this would be the OpenJDK tag, for hotspot JDK11+ this would be the Adopt merge tag for the desired OpenJDK tag eg.jdk-11.0.4+10_adopt, and for OpenJ9 this will be the release branch, eg.openj9-0.14.0.')
stringParam('scmReference', "", 'Tag name or Branch name from which openjdk source code repo to build. Nightly builds: Defaults to, Hotspot=dev, OpenJ9=openj9, others=master.</br>Release builds: For hotspot JDK8 this would be the OpenJDK tag, for hotspot JDK11+ this would be the Adopt merge tag for the desired OpenJDK tag eg.jdk-11.0.4+10_adopt, and for OpenJ9 this will be the release branch, eg.openj9-0.14.0.')
stringParam('buildReference', "", 'Tag name or Branch name of temurin-build repo. Defaults to master')
stringParam('ciReference', "", 'Tag name or Branch name of ci-jenkins-pipeline repo. Defaults to master')
stringParam('helperReference', "", 'Tag name or Branch name of jenkins-helper repo. Defaults to master')
Expand All @@ -113,6 +113,6 @@ pipelineJob("${BUILD_FOLDER}/${JOB_NAME}") {
booleanParam('keepReleaseLogs', true, 'If true, "Release" type pipeline Jenkins logs will be marked as "Keep this build forever".')
stringParam('adoptBuildNumber', "", "Empty by default. If you ever need to re-release then bump this number. Currently this is only added to the build metadata file.")
textParam('defaultsJson', JsonOutput.prettyPrint(JsonOutput.toJson(defaultsJson)), '<strong>DO NOT ALTER THIS PARAM UNLESS YOU KNOW WHAT YOU ARE DOING!</strong> This passes down the user\'s default constants to the downstream jobs.')
textParam('adoptDefaultsJson', JsonOutput.prettyPrint(JsonOutput.toJson(adoptDefaultsJson)), '<strong>DO NOT ALTER THIS PARAM UNDER ANY CIRCUMSTANCES!</strong> This passes down adopt\'s default constants to the downstream jobs. NOTE: <code>defaultsJson</code> has priority, the constants contained within this param will only be used as a failsafe.')
textParam('adoptDefaultsJson', JsonOutput.prettyPrint(JsonOutput.toJson(adoptDefaultsJson)), '<strong>DO NOT ALTER THIS PARAM UNDER ANY CIRCUMSTANCES!</strong> This passes down adoptium\'s default constants to the downstream jobs. NOTE: <code>defaultsJson</code> has priority, the constants contained within this param will only be used as a failsafe.')
}
}
2 changes: 2 additions & 0 deletions pipelines/src/test/groovy/RepoHandlerTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class RepoHandlerTest {
Assertions.assertEquals(adoptJson.repository.build_branch, "master")
Assertions.assertEquals(adoptJson.repository.pipeline_url, "https://github.com/adoptium/ci-jenkins-pipelines.git")
Assertions.assertEquals(adoptJson.repository.pipeline_branch, "master")
Assertions.assertEquals(adoptJson.repository.helper_ref, "master")

// Jenkins Details
Assertions.assertTrue(adoptJson.jenkinsDetails instanceof Map)
Expand Down Expand Up @@ -78,6 +79,7 @@ class RepoHandlerTest {
Assertions.assertEquals(userJson.repository.build_branch, "20")
Assertions.assertEquals(userJson.repository.pipeline_url, "19")
Assertions.assertEquals(userJson.repository.pipeline_branch, "21")
Assertions.assertEquals(userJson.repository.helper_ref, "24")

// Jenkins Details
Assertions.assertTrue(userJson.jenkinsDetails instanceof Map)
Expand Down
3 changes: 2 additions & 1 deletion pipelines/src/test/groovy/fakeDefaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"build_url" : "1",
"build_branch" : "20",
"pipeline_url" : "19",
"pipeline_branch" : "21"
"pipeline_branch" : "21",
"helper_ref" : "24"
},
"jenkinsDetails" : {
"rootUrl" : "3",
Expand Down