feat: Add option to preserve directory structure for attachments (#165)#170
feat: Add option to preserve directory structure for attachments (#165)#170MJB222398 wants to merge 3 commits into
Conversation
|
Hi @jonesbusy any input on this? |
|
Not yet didn't had time to test and take a look |
|
What about a shorter term like
Not a native English speaker here, so I'm not sure what would be the best Any advice on that PR @jenkinsci/junit-attachments-plugin-developers? |
|
Hi @jonesbusy yes I can change it to that no problem. I don't think your tag worked by the way, those people will not be notified |
|
Using following pipeline I'm not abable to use this new option pipeline {
agent {
label('built-in')
}
stages {
stage('Write tests') {
steps {
sh('mkdir -p bar')
writeFile(encoding: 'UTF-8', file: 'bar/foo.txt', text: 'hi')
writeFile(encoding: 'UTF-8', file: 'junit.xml', text: '<testsuites id="" name="" tests="1" failures="0" skipped="0" errors="0" time="9.653876"><testsuite name="ui.spec.ts" timestamp="2025-03-14T05:08:00.043Z" hostname="firefox" tests="1" failures="0" skipped="0" time="5.293" errors="0"><testcase name="should add todo" classname="ui.spec.ts" time="5.293"><system-out>[[ATTACHMENT|bar/foo.txt]]</system-out></testcase></testsuite></testsuites>')
}
}
stage('Record junit') {
steps {
script {
def summary = junit(testResults: 'junit.xml', testDataPublishers: [attachments(keepAttachmentsDirectories: true)])
}
}
}
}
}I expect to see my attachement inside the 'bar' directory but it's not the case apparently Also when I check the file system the attachement is not stored inside any 'bar' directory Any idea? |
|
@jonesbusy I was using 'Freestyle project' and configuring using the gui where it works. Does doing that work for you? I tried creating a 'Pipeline' job and pasted in your code above. I ran it and it says it was a success but I do not even see a Test Report produced? How can I create a job to reproduce what you are seeing? |
|
Might be partially fixed by #203 Putting in draft if there is still interest to resolve conflict and ensure it works with pipeline as well |

This adds the option to be able to preserve the original directory structure of any attachments. With the option enabled it will determine the common base path for all the attachments for each test case. It will then maintain that relative directory structure when archiving the attachments for the build.
Testing done
Tested for old builds created before change. Tested for new builds with and without option set.
Submitter checklist