-
-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collecting release tap files (#5404)
* Initail JenkinsFile Signed-off-by: Sophia Guo <[email protected]> * Initial tap collection jenkinsfile Signed-off-by: Sophia Guo <[email protected]> * Format update Signed-off-by: Sophia Guo <[email protected]> --------- Signed-off-by: Sophia Guo <[email protected]>
- Loading branch information
1 parent
fc2504b
commit d98becb
Showing
1 changed file
with
86 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,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() | ||
} | ||
} | ||
} |