forked from openshift-eng/aos-cd-jobs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_artifacts.py
More file actions
36 lines (29 loc) · 1.24 KB
/
generate_artifacts.py
File metadata and controls
36 lines (29 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from __future__ import absolute_import, print_function, unicode_literals
from jinja2 import Template
from actions.named_shell_task import render_task
from .interface import Action
_GENERATE_ARTIFACTS_TITLE = "GENERATE ARTIFACTS FROM THE REMOTE HOST"
_GENERATE_ARTIFACTS_ACTION_TEMPLATE = Template("""trap 'exit 0' EXIT
ARTIFACT_DIR="$( pwd )/artifacts/generated"
rm -rf "${ARTIFACT_DIR}"
mkdir "${ARTIFACT_DIR}"
{%- for name, action in artifacts.iteritems() %}
ssh -F ${WORKSPACE}/.config/origin-ci-tool/inventory/.ssh_config openshiftdevel "{{ action }} 2>&1" >> "${ARTIFACT_DIR}/{{ name }}" || true
{%- endfor %}
tree "${ARTIFACT_DIR}" """)
class GenerateArtifactsAction(Action):
"""
A GenerateArtifactsAction generates a post-build
step which generates the given files from actions
taken on the remote host.
"""
def __init__(self, artifacts):
# we expect `artifacts` to be a dictionary of
# artifact name --> generating action
self.artifacts = artifacts
def generate_post_build_steps(self):
return [render_task(
title=_GENERATE_ARTIFACTS_TITLE,
command=_GENERATE_ARTIFACTS_ACTION_TEMPLATE.render(artifacts=self.artifacts),
output_format=self.output_format
)]