-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
116 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env python3 | ||
# author: Jan Hybs | ||
|
||
import sys | ||
|
||
|
||
try: | ||
import cihpc.git_tools | ||
except ImportError as e: | ||
print(sys.executable, sys.version) | ||
print('sys.path:') | ||
for i in range(len(sys.path)): | ||
print('%2d) %s' % (i + 1, sys.path[i])) | ||
raise | ||
|
||
|
||
print('cihpc-hook v%s' % cihpc.__version__, sys.executable, str(sys.version).replace('\n', ' ')) | ||
sys.exit( | ||
cihpc.git_tools.main() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
# args are following | ||
REPO = $1 | ||
COMMIT = $2 | ||
|
||
|
||
$CIHPC_HOME/bin/cihpc -p $REPO --commit $COMMIT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
# args are following | ||
REPO = $1 | ||
COMMIT = $2 | ||
|
||
|
||
#$CIHPC_HOME/bin/cihpc -p $REPO --commit $COMMIT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/python3 | ||
# author: Jan Hybs | ||
|
||
|
||
class AbstractWebhookTrigger(object): | ||
|
||
def process(self, payload): | ||
""" | ||
Parameters | ||
---------- | ||
payload: cihpc.common.utils.git.webhooks.push_hook.PushWebhook | ||
payload to process | ||
Returns | ||
------- | ||
bool | ||
True on success False otherwise | ||
""" | ||
raise NotImplementedError('Not implemented!') | ||
|
||
def wait(self): | ||
raise NotImplementedError('Not implemented!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/python3 | ||
# author: Jan Hybs | ||
|
||
|
||
import logging | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
import os | ||
import subprocess | ||
|
||
from cihpc.cfg.config import global_configuration | ||
from cihpc.git_tools.triggers import AbstractWebhookTrigger | ||
|
||
|
||
class ShellTrigger(AbstractWebhookTrigger): | ||
|
||
def __init__(self, trigger_path=None): | ||
self.trigger_path = trigger_path | ||
self._process = None | ||
|
||
def process(self, payload): | ||
project = payload.repository.name | ||
commit = payload.after | ||
|
||
trigger_path = self.trigger_path or os.path.join(global_configuration.cwd, 'triggers', 'local-trigger') | ||
args = ['bash', trigger_path, project, commit] | ||
|
||
self._process = subprocess.Popen(args) | ||
|
||
def wait(self): | ||
self._process.wait() | ||
logger.info('trigger ended with %d' % self._process.returncode) | ||
return self._process.returncode | ||
|