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

Initial commit for jck_sync job #4715

Merged
merged 5 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
106 changes: 106 additions & 0 deletions buildenv/jenkins/jck_sync
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!groovy

timestamps{
stage('Setup') {
if (params.LABEL !="") {
LABEL = params.LABEL
} else {
LABEL = "ci.role.test&&hw.arch.x86&&sw.os.linux"
}
node(LABEL) {
println "LABEL: ${LABEL}"
echo "clone the SCM GIT repo"
try {
def gitConfig = scm.getUserRemoteConfigs().get(0)
timeout(time: 1, unit: 'HOURS') {
forceCleanWS()
}
KapilPowar marked this conversation as resolved.
Show resolved Hide resolved
checkout scm: [$class: 'GitSCM',
branches: [[name: "${scm.branches[0].name}"]],
extensions: [
[$class: 'CleanBeforeCheckout'],
[$class: 'CloneOption'],
[$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'
}

}
}
}
}

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 ? "-j ${params.JDK_VERSION}": ""
def JCK_GIT_BRANCH = params.JCK_GIT_BRANCH ? "-gb ${params.JCK_GIT_BRANCH}": ""
def ARTIFACTORY_URL = params.ARTIFACTORY_URL ? "-au ${params.ARTIFACTORY_URL}": ""
def JCK_GIT_REPO = params.JCK_GIT_REPO ? "-repo ${params.JCK_GIT_REPO}": ""
KapilPowar marked this conversation as resolved.
Show resolved Hide resolved
stage('Build') {
KapilPowar marked this conversation as resolved.
Show resolved Hide resolved
script {
getJavaSDK()

withCredentials([
usernamePassword(credentialsId: "${params.ARTIFACTORY_CREDENTIALS}",
usernameVariable: 'ARTIFACTORY_USER', passwordVariable: 'ARTIFACTORY_CREDENTIALS'),
string(credentialsId: "${params.GIT_CREDENTIALS}",variable: 'GIT_CREDENTIALS')
]) {
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} -at ${ARTIFACTORY_CREDENTIALS} ${JCK_GIT_REPO} -gt ${GIT_CREDENTIALS} ${ARTIFACTORY_URL} ${JCK_GIT_BRANCH}"
echo "${SCRIPT}"
def EXITCODE = sh(script: "${SCRIPT}", returnStatus: true)
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."
} else {
error("script failed with exit code ${EXITCODE}")
}
}
}
}
}
}
}

//Download JAVA SDK
def getJavaSDK(){

JDK_VERSION_OPTION = params.JDK_VERSION ? "-j ${params.JDK_VERSION}" : ""
JDK_IMPL_OPTION = params.JDK_IMPL ? "-i ${params.JDK_IMPL}" : ""
CUSTOMIZED_SDK_URL_OPTION = "-c ${params.CUSTOMIZED_SDK_URL}"

GET_SH_CMD = "./get.sh -s `pwd`/.. -p $PLATFORM -r ${SDK_RESOURCE} ${JDK_VERSION_OPTION} ${JDK_IMPL_OPTION} ${CUSTOMIZED_SDK_URL_OPTION} "
KapilPowar marked this conversation as resolved.
Show resolved Hide resolved
dir("${WORKSPACE}/aqa-tests") {
sshagent(credentials:["${params.USER_CREDENTIALS_ID}"], ignoreMissing: true) {
KapilPowar marked this conversation as resolved.
Show resolved Hide resolved
sh "$GET_SH_CMD"
}
}
}
51 changes: 51 additions & 0 deletions jck/jck-semiauto-updater/README.md
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/artifactory/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)
JCK_GIT_REPO - The JCK GIT repo to update.(e.g. [email protected]:runtimes/JCK8-unzipped.git)
ARTIFACTORY_TOKEN - Artifactory token to download JCK resources from https://eu.artifactory.swg-devops.com/artifactory/jim-jck-generic-local
ARTIFACTORY_DOWNLOAD_URL - Artifactory server URL to download JCK resources. Default value is https://eu.artifactory.swg-devops.com/artifactory/jim-jck-generic-local
GIT_TOKEN - GIT user's API Token to create PR.
JCK_GIT_BRANCH - Branch to Pull and merge resources. Default value autoBranch.
JAVA_HOME - Path to JDK on system. 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
```


Loading