-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create jck_sync job Add arguments for jck_sync job Initial commit for jck_sync job
- Loading branch information
1 parent
67a4672
commit 717c162
Showing
3 changed files
with
664 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,251 @@ | ||
#!groovy | ||
|
||
def PLATFORM_MAP = [ | ||
'arm_linux' : [ | ||
'SPEC' : 'linux_arm', | ||
'LABEL' : 'ci.role.test&&sw.os.linux&&hw.arch.aarch32', | ||
], | ||
'aarch64_mac' : [ | ||
'SPEC' : 'osx_aarch64', | ||
'LABEL' : 'ci.role.test&&hw.arch.aarch64&&(sw.os.osx||sw.os.mac)', | ||
], | ||
'aarch64_linux' : [ | ||
'SPEC' : 'linux_aarch64', | ||
'LABEL' : 'ci.role.test&&sw.os.linux&&hw.arch.aarch64', | ||
], | ||
'aarch64_windows' : [ | ||
'SPEC' : 'windows_aarch64', | ||
'LABEL' : 'ci.role.test&&sw.os.windows&&hw.arch.aarch64', | ||
], | ||
'aarch64_alpine-linux' : [ | ||
'SPEC' : 'alpine-linux_aarch64', | ||
'LABEL' : 'ci.role.test&&hw.arch.aarch64&&sw.os.alpine-linux', | ||
], | ||
'ppc32_aix' : [ | ||
'SPEC' : 'aix_ppc', | ||
'LABEL' : 'ci.role.test&&hw.arch.ppc64&&sw.os.aix', | ||
], | ||
'ppc32_linux' : [ | ||
'SPEC' : 'linux_ppc', | ||
'LABEL' : 'ci.role.test&&hw.arch.ppc64&&sw.os.linux', | ||
], | ||
'ppc64_aix' : [ | ||
'SPEC' : 'aix_ppc-64', | ||
'LABEL' : 'ci.role.test&&hw.arch.ppc64&&sw.os.aix', | ||
], | ||
'ppc64_linux' : [ | ||
'SPEC' : 'linux_ppc-64', | ||
'LABEL' : 'ci.role.test&&hw.arch.ppc64&&sw.os.linux', | ||
], | ||
'ppc64le_linux' : [ | ||
'SPEC' : 'linux_ppc-64_le', | ||
'LABEL' : 'ci.role.test&&hw.arch.ppc64le&&sw.os.linux', | ||
'DynamicAgents' : ['fyre'] | ||
], | ||
'riscv64_linux' : [ | ||
'SPEC' : 'linux_riscv64', | ||
'LABEL' : 'ci.role.test&&sw.os.linux&&hw.arch.riscv', | ||
'DockerAgents' : ['default'] | ||
], | ||
'riscv64_linux_xl' : [ | ||
'SPEC' : 'linux_riscv64', | ||
'LABEL' : 'ci.role.test&&sw.os.linux&&hw.arch.riscv&&hw.bits.64', | ||
], | ||
's390_linux' : [ | ||
'SPEC' : 'linux_390', | ||
'LABEL' : 'ci.role.test&&hw.arch.s390x&&sw.os.linux&&hw.bits.32', | ||
], | ||
's390x_linux_zt' : [ | ||
'SPEC' : 'linux_390-64_zt', | ||
'LABEL' : 'ci.role.test&&hw.arch.znext&&sw.os.linux', | ||
], | ||
's390x_linux' : [ | ||
'SPEC' : 'linux_390-64', | ||
'LABEL' : 'ci.role.test&&hw.arch.s390x&&sw.os.linux', | ||
], | ||
's390x_zos' : [ | ||
'SPEC' : 'zos_390-64', | ||
'LABEL' : 'ci.role.test&&hw.arch.s390x&&sw.os.zos', | ||
], | ||
's390x_zos_xl' : [ | ||
'SPEC' : 'zos_390-64', | ||
'LABEL' : 'ci.role.test&&hw.arch.s390x&&sw.os.zos', | ||
], | ||
's390x_zos_zt' : [ | ||
'SPEC' : 'zos_390-64_zt', | ||
'LABEL' : 'ci.role.test&&hw.arch.znext&&sw.os.zos', | ||
], | ||
's390_zos_zt' : [ | ||
'SPEC' : 'zos_390_zt', | ||
'LABEL' : 'ci.role.test&&hw.arch.znext&&sw.os.zos', | ||
], | ||
's390_zos' : [ | ||
'SPEC' : 'zos_390', | ||
'LABEL' : 'ci.role.test&&hw.arch.s390x&&sw.os.zos', | ||
], | ||
'sparcv9_solaris' : [ | ||
'SPEC' : 'sunos_sparcv9-64', | ||
'LABEL' : 'ci.role.test&&hw.arch.sparcv9&&sw.os.sunos', | ||
], | ||
'x86-64_solaris' : [ | ||
'SPEC' : 'sunos_x86-64', | ||
'LABEL' : 'ci.role.test&&hw.arch.x86&&sw.os.sunos', | ||
], | ||
'x86-64_alpine-linux' : [ | ||
'SPEC' : 'alpine-linux_x86-64', | ||
'LABEL' : 'ci.role.test&&hw.arch.x86&&sw.os.alpine-linux', | ||
], | ||
'x86-32_linux' : [ | ||
'SPEC' : 'linux_x86', | ||
'LABEL' : 'ci.role.test&&hw.arch.x86&&sw.os.linux', | ||
], | ||
'x86-32_windows' : [ | ||
'SPEC' : 'win_x86', | ||
'LABEL' : 'ci.role.test&&hw.arch.x86&&sw.os.windows', | ||
], | ||
'x86-64_linux' : [ | ||
'SPEC' : 'linux_x86-64', | ||
'LABEL' : 'ci.role.test&&hw.arch.x86&&sw.os.linux', | ||
'DynamicAgents' : ['azure', 'fyre'] | ||
], | ||
'x86-64_mac' : [ | ||
'SPEC' : 'osx_x86-64', | ||
'LABEL' : 'ci.role.test&&hw.arch.x86&&(sw.os.osx||sw.os.mac)', | ||
], | ||
'x86-64_windows' : [ | ||
'SPEC' : 'win_x86-64', | ||
'LABEL' : 'ci.role.test&&hw.arch.x86&&sw.os.windows', | ||
], | ||
] | ||
|
||
timestamps{ | ||
stage('Setup') { | ||
if (PLATFORM_MAP.containsKey(params.PLATFORM)) { | ||
SPEC = PLATFORM_MAP[params.PLATFORM]["SPEC"] | ||
if (params.LABEL) { | ||
LABEL = params.LABEL | ||
} else { | ||
LABEL = PLATFORM_MAP[params.PLATFORM]["LABEL"] | ||
} | ||
node(LABEL) { | ||
echo "clone the SCM GIT repo" | ||
try { | ||
def retry_count = 0 | ||
def sleep_time = 180 | ||
def gitConfig = scm.getUserRemoteConfigs().get(0) | ||
// Adopt windows machines require env here https://github.com/adoptium/aqa-tests/issues/1803 | ||
ref_cache = "${env.HOME}/openjdk_cache" | ||
retry(5) { | ||
if (retry_count > 0) { | ||
sleep(sleep_time) | ||
} | ||
retry_count++ | ||
timeout(time: 1, unit: 'HOURS') { | ||
forceCleanWS() | ||
} | ||
checkout scm: [$class: 'GitSCM', | ||
branches: [[name: "${scm.branches[0].name}"]], | ||
extensions: [ | ||
[$class: 'CleanBeforeCheckout'], | ||
[$class: 'CloneOption', reference: ref_cache], | ||
[$class: 'RelativeTargetDirectory', relativeTargetDir: 'aqa-tests']], | ||
userRemoteConfigs: [[url: "${gitConfig.getUrl()}"]] | ||
] | ||
} | ||
syncJckMaterial() | ||
|
||
} catch (Exception e) { | ||
println("Exception: " + e.toString()) | ||
// build result may not be updated correctly at the moment (see https://issues.jenkins.io/browse/JENKINS-56402) | ||
// if there is an exception, set currentBuild.result to ABORTED/FAILURE | ||
if (e.toString().contains("FlowInterruptedException")) { | ||
currentBuild.result = 'ABORTED' | ||
} else { | ||
currentBuild.result = 'FAILURE' | ||
} | ||
|
||
} | ||
} | ||
} else { | ||
assert false : "Cannot find key PLATFORM: ${params.PLATFORM} in PLATFORM_MAP: ${PLATFORM_MAP}." | ||
} | ||
} | ||
} | ||
|
||
def forceCleanWS() { | ||
try { | ||
cleanWs disableDeferredWipeout: true, deleteDirs: true | ||
} catch (Exception e) { | ||
echo 'Exception: ' + e.toString() | ||
//cleanWs has issue to delete workspace that contains non-ASCII filename in TKG output https://issues.jenkins.io/browse/JENKINS-33478 | ||
//cannot delete workspace directly. Otherwise, Jenkins job will abort due to missing workspace | ||
sh "rm -rf ${env.WORKSPACE}/aqa-tests/TKG" | ||
// call cleanWs() again | ||
cleanWs disableDeferredWipeout: true, deleteDirs: true | ||
} | ||
} | ||
|
||
def syncJckMaterial(){ | ||
echo "Starting script to sync JCK materials ....." | ||
|
||
def JCK_VERSION = params.JDK_VERSION ?: "" | ||
def GIT_DEV_BRANCH = params.JCK_GIT_BRANCH ?: "" | ||
def JAVA_HOME = params.JAVA_HOME ?: "" | ||
def JAVA_SDK_URL = params.JAVA_SDK_URL ?: "" | ||
def JCK_GIT_REPO = params.JCK_GIT_REPO ?: "" | ||
def JCK_VERSION_FLAG = JCK_VERSION ? "-j" : "" | ||
def GIT_DEV_BRANCH_FLAG = GIT_DEV_BRANCH ? "-gb" : "" | ||
def JAVA_HOME_FLAG = JAVA_HOME ? "-java" : "" | ||
def JAVA_SDK_URL_FLAG = JAVA_SDK_URL ? "-sdk_url" : "" | ||
def GIT_USER = params.GIT_USER ?: "" | ||
def EXITCODE = 0 | ||
def jenkinsfile = load "${WORKSPACE}/aqa-tests/buildenv/jenkins/JenkinsfileBase" | ||
|
||
stage('Build') { | ||
script { | ||
jenkinsfile.setup() | ||
|
||
withCredentials([ | ||
usernamePassword(credentialsId: "${params.ARTIFACTORY_CREDENTIALS}", | ||
usernameVariable: 'ARTIFACTORY_USER', passwordVariable: 'ARTIFACTORY_CREDENTIALS'), | ||
string(credentialsId: "${params.GIT_CREDENTIALS}",variable: 'GIT_CREDENTIALS') | ||
]) { | ||
// IF no custom GIT user provided, use runtimes main repo for j9build. | ||
if (GIT_USER == "j9build"){ | ||
GIT_USER= "runtimes" | ||
} | ||
echo "GIT user -- ${GIT_USER}" | ||
def currentDirectory = sh(script: 'pwd', returnStdout: true).trim() | ||
dir("${currentDirectory}/aqa-tests/jck/jck-semiauto-updater") { | ||
sshagent(credentials:["${params.USER_CREDENTIALS_ID}"], ignoreMissing: true){ | ||
def SCRIPT = "./jckupdater.sh ${JCK_VERSION_FLAG} ${JCK_VERSION} -at ${ARTIFACTORY_CREDENTIALS} -u ${GIT_USER} -gt ${GIT_CREDENTIALS} ${GIT_DEV_BRANCH_FLAG} ${GIT_DEV_BRANCH} ${JAVA_HOME_FLAG} ${JAVA_HOME} ${JAVA_SDK_URL_FLAG} ${JAVA_SDK_URL}" | ||
echo "${SCRIPT}" | ||
def scriptResult = sh(script: "${SCRIPT}", returnStatus: true) | ||
EXITCODE = scriptResult | ||
echo "EXITCODE= ${EXITCODE}" | ||
if (EXITCODE == 2) { | ||
echo "script returned exit code 2, No new update available. Marking the job as SUCCESS. " | ||
} else if (EXITCODE == 0) { | ||
echo "script returned exit code 0, new update is available and PR is created, proceeding to Stage 2." | ||
} else { | ||
error("script failed with exit code ${EXITCODE}") | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
} | ||
stage('SanityTest') { | ||
script{ | ||
if (EXITCODE==0){ | ||
jenkinsfile.addJobDescription() | ||
jenkinsfile.addGrinderLink() | ||
jenkinsfile.testExecution() | ||
jenkinsfile.terminateTestProcesses() | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Overview | ||
|
||
The jckupdater.sh script automates the process of obtaining JCK materials from https://eu.artifactory.swg-devops.com/ui/repos/tree/General/jim-jck-generic-local site and pushing them in the IBM internal repository. | ||
|
||
# How to run the script | ||
|
||
The following instructions may be used to run jckupdater.sh to make a JCK update | ||
|
||
- Create a fork of the internal JCK repository (if it doesn't already exist) to create the pull request. | ||
- Run the script with following arguments: | ||
|
||
``` | ||
JCK_VERSION - The JCK version for which the update is being performed (e.g. 8, 11, 12 etc) | ||
GIT_USER - The GIT user to be used to create the PR. | ||
TOKEN - Artifactory token to download JCK resources from https://eu.artifactory.swg-devops.com/ui/repos/tree/General/jim-jck-generic-local | ||
GIT_TOKEN - GIT user's API Token to create PR. | ||
DEVELOPER_BRANCH - Branch to Pull and merge resources. Default value main. | ||
JAVA_HOME - Path to JDK on system. Optional. | ||
JAVA_SDK_URL - URL to download JDK. Optional. | ||
``` | ||
|
||
# What the script automates: | ||
|
||
``` | ||
1) Checks if latest update is available in artifcatory. If not available then exits without proceeding. | ||
2) If available then downloads the JCK material Jars on local disc. | ||
3) Installs JCK material Jars on local disc. | ||
4) Initializes Git at the local machine, and configures the remotes and origins. | ||
5) Checks out existing JCK materials from the internal Git repository. | ||
6) If changes are present then Commit to local repo and push it to Git branch. | ||
7) Creates PR for review from origin to Base repo ie. runtime. | ||
``` | ||
|
||
|
||
# Functions | ||
The script contains the following function calls: | ||
|
||
``` | ||
setup | ||
isLatestUpdate | ||
getJCKSources | ||
extract | ||
gitClone | ||
copyFilestoGITRepo | ||
checkChangesAndCommit | ||
createPR | ||
cleanup | ||
``` | ||
|
||
|
Oops, something went wrong.