From 98dbcc16f0f3e75a12722aee6f1e6d2aea654f35 Mon Sep 17 00:00:00 2001 From: Andreas Resch Date: Thu, 11 Jan 2024 16:17:20 +0100 Subject: [PATCH] fix make aeolus more artemis compatible --- cli/generators/base.py | 2 ++ cli/generators/jenkins.py | 10 ++++++++-- cli/templates/Jenkinsfile.j2 | 25 ++++++++++++++----------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/cli/generators/base.py b/cli/generators/base.py index 5895ed9f..8d8aae28 100644 --- a/cli/generators/base.py +++ b/cli/generators/base.py @@ -117,6 +117,8 @@ def add_result(self, workdir: str, result: Result) -> None: """ Add a result to the results dictionary. """ + if workdir is None: + workdir = "." if workdir not in self.results: self.results[workdir] = [] self.results[workdir].append(result) diff --git a/cli/generators/jenkins.py b/cli/generators/jenkins.py index 5c2526b3..6b5ba4f1 100644 --- a/cli/generators/jenkins.py +++ b/cli/generators/jenkins.py @@ -87,6 +87,11 @@ def publish(self) -> None: false + + + + + """ @@ -121,6 +126,9 @@ def generate_using_jinja2(self) -> str: if action.root.platform and action.root.platform != Target.jenkins: continue actions.append(action) + if action.root.results: + for result in action.root.results: + self.add_result(action.root.workdir, result) data: dict[str, typing.Any] = { "docker": self.windfile.metadata.docker, @@ -131,8 +139,6 @@ def generate_using_jinja2(self) -> str: "steps": [action.root for action in actions if not action.root.runAlways], "always_steps": [action.root for action in actions if action.root.runAlways], "metadata": self.windfile.metadata, - "before_results": self.before_results, - "after_results": self.after_results, "repo_metadata": self.metadata.get(scope="repositories"), "has_results": self.has_results(), "results": self.results, diff --git a/cli/templates/Jenkinsfile.j2 b/cli/templates/Jenkinsfile.j2 index 8aeda5ab..b146e377 100644 --- a/cli/templates/Jenkinsfile.j2 +++ b/cli/templates/Jenkinsfile.j2 @@ -41,7 +41,6 @@ pipeline { {%- for name, repository in repositories.items() %} stage('{{ name }}') { steps { - echo '🖨️ cloning {{ name }}' dir('{{ repository.path }}') { checkout([$class: 'GitSCM', branches: [[name: '{{ repository.branch }}']], @@ -93,7 +92,6 @@ pipeline { {%- endif %} {%- endif %} steps { - echo '⚙️ executing {{ step.name }}' {%- if step.workdir %} dir('{{ step.workdir }}') { sh ''' @@ -114,7 +112,6 @@ pipeline { post { always { {%- for action in always_steps %} - echo '⚙️ executing {{ action.name }}' {%- if action.workdir %} dir('{{ action.workdir }}') { sh ''' @@ -128,27 +125,33 @@ post { {%- endif %} {%- endfor %} {%- if has_results %} - echo '📊 publishing results' {%- for workdir, entries in results.items() %} dir('{{ workdir }}') { {%- for result in entries %} - {%- if result.type == 'junit' %} - junit './{{ result.path }}' + {#%- if result.type == 'junit' %} + {#junit './{{ result.path }}' {%- else %} archiveArtifacts: './{{result.path}}', fingerprint: true, allowEmptyArchive: true, {%- endif %} + would be cool, but artemis does not work with this #} + sh ''' + mkdir -p results || true + cp {{ result.path }} $WORKSPACE/results/ || true + sed -i 's/[^[:print:] ]/�/g' $WORKSPACE/{{ result.path }} || true + ''' {%- endfor %} } {%- endfor %} {%- if metadata.resultHook %} - {%- if metadata.resultHookCredentials %} - sendTestResults credentialsId: '{{ metadata.resultHookCredentials }}', notificationUrl: '{{ metadata.resultHook }}' - {%- else %} - sendTestResults notificationUrl: '{{ metadata.resultHook }}' - {%- endif %} + {%- if metadata.resultHookCredentials %} + sendTestResults credentialsId: '{{ metadata.resultHookCredentials }}', notificationUrl: '{{ metadata.resultHook }}' + {%- else %} + sendTestResults notificationUrl: '{{ metadata.resultHook }}' + {%- endif %} {%- endif %} {%- endif %} {%- if has_always_actions or has_results %} + cleanWs() } } {%- endif %}