Skip to content

Commit

Permalink
fix make aeolus more artemis compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
reschandreas committed Jan 11, 2024
1 parent 7613bb6 commit 98dbcc1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
2 changes: 2 additions & 0 deletions cli/generators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions cli/generators/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ def publish(self) -> None:
</definition>
<triggers/>
<disabled>false</disabled>
<properties>
<hudson.security.AuthorizationMatrixProperty>
<inheritanceStrategy class="org.jenkinsci.plugins.matrixauth.inheritance.InheritParentStrategy"/>
</hudson.security.AuthorizationMatrixProperty>
</properties>
</flow-definition>
"""

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
25 changes: 14 additions & 11 deletions cli/templates/Jenkinsfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}']],
Expand Down Expand Up @@ -93,7 +92,6 @@ pipeline {
{%- endif %}
{%- endif %}
steps {
echo '⚙️ executing {{ step.name }}'
{%- if step.workdir %}
dir('{{ step.workdir }}') {
sh '''
Expand All @@ -114,7 +112,6 @@ pipeline {
post {
always {
{%- for action in always_steps %}
echo '⚙️ executing {{ action.name }}'
{%- if action.workdir %}
dir('{{ action.workdir }}') {
sh '''
Expand All @@ -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 %}
Expand Down

0 comments on commit 98dbcc1

Please sign in to comment.