@@ -127,12 +127,16 @@ node('high-cpu') {
127127 script : " groovy ./scripts/e2e.groovy --url http://${ k3dAddress} :9090 --user admin --password admin --writeFailedLog --fail --retry 2" )
128128 }
129129
130- if (ret > 0 ) {
130+ if (ret > 0 ) {
131131 if (fileExists(' playground-logs-of-failed-jobs' )) {
132132 archiveArtifacts artifacts : ' playground-logs-of-failed-jobs/*.log'
133133 }
134134 unstable " Integration tests failed, see logs appended to jobs and cluster status in logs"
135- sh " docker exec k3d-${ clusterName} -server-0 kubectl get all -A"
135+
136+ kubectlToFile(clusterName," allPods.txt" ," get all -A" )
137+
138+ printIntegrationTestLogs(clusterName,' app=scm-manager' )
139+ printIntegrationTestLogs(clusterName,' app.kubernetes.io/name=jenkins' )
136140 }
137141 }
138142
@@ -243,6 +247,20 @@ def trivy(String imageName, Map additionalTrivyConfig = [:]) {
243247 trivyConfig. additionalFlags + = ' --java-db-repository public.ecr.aws/aquasecurity/trivy-java-db'
244248
245249 findVulnerabilitiesWithTrivy(trivyConfig)
250+
251+ }
252+
253+ def printIntegrationTestLogs (String clusterName , String appSelector , String namespace = ' default' ){
254+ def filename= appSelector. split(" =" )
255+
256+ kubectlToFile(clusterName, " ${ filename[1]} .log" , " logs -n ${ namespace} -l ${ appSelector} --tail=-1" )
257+ kubectlToFile(clusterName, " ${ filename[1]} -previous.log" , " logs -n ${ namespace} -l ${ appSelector} --tail=-1 -p" )
258+ kubectlToFile(clusterName, " ${ filename[1]} -describe.txt" , " describe pods -n ${ namespace} -l ${ appSelector} " )
259+ }
260+
261+ void kubectlToFile (String clusterName , String filename , String command ) {
262+ sh " docker exec k3d-${ clusterName} -server-0 kubectl ${ command} | tee ${ filename} "
263+ archiveArtifacts artifacts : " ${ filename} " , allowEmptyArchive : true
246264}
247265
248266def startK3d (clusterName ) {
0 commit comments