forked from adoptium/aqa-tests
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sophia Guo <[email protected]>
- Loading branch information
1 parent
1eae88f
commit c7a115d
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,64 @@ | ||
pipeline { | ||
agent { label 'ci.role.test&&hw.arch.x86&&sw.os.linux' } | ||
environment { | ||
GITHUB_TOKEN = credentials('') | ||
REPO_OWNER = 'sophia-guo' | ||
REPO_NAME = 'openjdk-tests' | ||
ISSUE_NUMBER = "https://github.com/adoptium/aqa-tests/issues/5235" | ||
DOWNLOAD_DIR ='download' | ||
} | ||
stages { | ||
stage('Download Attachments') { | ||
steps { | ||
script { | ||
def issueUrl = "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/issues/${ISSUE_NUMBER}" | ||
def attachmentsDir = new File(DOWNLOAD_DIR) | ||
|
||
if (!attachmentsDir.exists()) { | ||
attachmentsDir.mkdirs() | ||
} | ||
|
||
def response = httpRequest ( | ||
url: issueUrl, | ||
customHeaders: [[name: 'Authorization', value: "token ${env.GITHUB_TOKEN}"]], | ||
acceptType: 'APPLICATION_JSON' | ||
) | ||
|
||
def issue = readJSON(text: response.content) | ||
def commentsUrl = issue.comments_url | ||
|
||
def commentsResponse = httpRequest ( | ||
url: commentsUrl, | ||
customHeaders: [[name: 'Authorization', value: "token ${env.GITHUB_TOKEN}"]], | ||
acceptType: 'APPLICATION_JSON' | ||
) | ||
|
||
def comments = readJSON(text: commentsResponse.content) | ||
comments.each { comment -> | ||
def body = comment.body | ||
def attachments = body.findAll(/https:\/\/.+\.txt/) | ||
|
||
attachments.each { attachmentUrl -> | ||
def fileName = attachmentUrl.tokenize('/').last() | ||
if (fileName.endsWith('.txt')) { | ||
echo "Downloading ${attachmentUrl}" | ||
def fileContent = httpRequest ( | ||
url: attachmentUrl, | ||
customHeaders: [[name: 'Authorization', value: "token ${env.GITHUB_TOKEN}"]], | ||
acceptType: 'APPLICATION_OCTETSTREAM' | ||
).content | ||
writeFile file: "${DOWNLOAD_DIR}/${fileName}", text: fileContent | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
post { | ||
always { | ||
archiveArtifacts artifacts: "${DOWNLOAD_DIR}/*.tap.txt", allowEmptyArchive: true | ||
cleanWs() | ||
} | ||
} |
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,45 @@ | ||
pipeline { | ||
agent { label 'ci.role.test&&hw.arch.x86&&sw.os.linux' } | ||
parameters { | ||
string(name: 'FILE_URL', defaultValue: '', description: 'URL to the uploaded artifacts') | ||
string(name: 'Release_PipelineJob_Name', defaultValue: '', description: 'Jenkins Pipeline job name') | ||
string(name: 'Release_PipelineJob_Number', defaultValue: '', description: 'Jenkins Pipeline job number') | ||
} | ||
stages { | ||
stage('Download and archive Artifacts') { | ||
steps { | ||
def tarDir = 'AQAvitTaps' | ||
def tarTap = 'AQAvitTapFiles.tar.gz' | ||
timeout(time: 1, unit: 'HOURS') { | ||
try { | ||
copyArtifacts (projectName: "${Release_PipelineJob_Name}", | ||
selector: specific("${Release_PipelineJob_Number}"), | ||
filter: '${tarDir}/${tarTap}', | ||
target: "${tarDir}/" | ||
} catch (Exception e) { | ||
echo 'Exception: ' + e.toString() | ||
echo "Cannot copy AQAvitTaps/AQAvitTapFiles.tar.gz from ${Release_PipelineJob_Name} with build id ${Release_PipelineJob_Number} . Skipping copyArtifacts..." | ||
} | ||
} | ||
script { | ||
|
||
def fileUrl = params.FILE_URL | ||
def fileName = "Grinder.tar.gz" | ||
sh """ | ||
cd ${tarDir}/ | ||
curl -L -o ${fileName} ${fileUrl} | ||
//untar Grinder.tar.gz | ||
//untar AQAvitTapFiles.tar.gz | ||
//tar new AQAvitTapFiles.tar.gz | ||
""" | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
archiveArtifacts artifacts: "${tarDir}/${tarTap}", allowEmptyArchive: true | ||
cleanWs() | ||
} | ||
} | ||
} |