Skip to content

Collecting release tap files #5404

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

Merged
merged 3 commits into from
Jun 28, 2024
Merged
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
86 changes: 86 additions & 0 deletions buildenv/jenkins/tapVerification/TapCollection.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
pipeline {
agent { label 'ci.role.test&&hw.arch.x86&&sw.os.linux' }
parameters {
string(name: 'RELEASE_TRIAGE_REPO', defaultValue: 'adoptium/aqa-tests', description: 'Triage repo')
string(name: 'RELEASE_TRIAGE_ISSUE_NUMBER', defaultValue: '', description: 'Triage issue number')
string(name: 'Release_PipelineJob_Name', defaultValue: '', description: 'Jenkins Pipeline job name')
string(name: 'Release_PipelineJob_Numbers', defaultValue: '', description: 'Jenkins Pipeline job number, Comma separated numbers')
}
stages {
stage('Tap Collection') {
steps {
script {
def issueUrl = "https://api.github.com/repos/${RELEASE_TRIAGE_REPO}/issues/${RELEASE_TRIAGE_ISSUE_NUMBER}"
def tapsDir = 'TAPs'
sh """
if [ ! -d "${tapsDir}" ]; then
mkdir -p "${tapsDir}"
fi
"""
def commentsUrl = "${issueUrl}/comments"
def issueFile = 'issue.json'
def commentsFile = 'comments.json'
withCredentials([string(credentialsId: "${params.GITHUB_CREDENTIAL}", variable: 'GITHUB_TOKEN')]) {
sh """
curl -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3-json" ${issueUrl} -o ${issueFile}
curl -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3-json" ${commentsUrl} -o ${commentsFile}
"""
}

def issue = readJSON file: "${issueFile}"
def comments = readJSON file: "${commentsFile}"

// Function to download attachments from text
def downloadAttachments = { text ->
text.split('\r\n').each { line ->
if (line.contains("https://github.com/${RELEASE_TRIAGE_REPO}/files/") && line.endsWith(')')) {
def url = line.substring(line.indexOf('(https') + 1, line.lastIndexOf(')'))
def filename = url.split('/').last()
sh "curl -L -o ${tapsDir}/${filename} ${url}"
}
}
}
// Download attachments from issue description
downloadAttachments(issue.body)

// Download attachments from issue comments
comments.each { comment ->
downloadAttachments(comment.body)
}
//Download Taps from upsteam
def builds = "${Release_PipelineJob_Numbers}".split(',')
def tapTars = "AQAvitTapFiles.tar.gz"
builds.each { build ->
echo "build is ${build}"
copyArtifacts (
filter: "AQAvitTaps/${tapTars}",
fingerprintArtifacts: true,
projectName: "${Release_PipelineJob_Name}",
selector: specific("${build}"),
target: "${build}/",
flatten: true
)
sh "tar -xzvf ${build}/${tapTars} -C ${tapsDir}"
}

sh """
cd ${tapsDir}/
tar -czf ${tapTars} *
"""
archiveArtifacts artifacts: "${tapsDir}/${tapTars}", allowEmptyArchive: true
}
}
}

stage('Verification') {
steps {
echo "Taps verification jobs"
}
}
}
post {
always {
cleanWs()
}
}
}