Skip to content

Commit

Permalink
use ssh_url for private github repos
Browse files Browse the repository at this point in the history
  • Loading branch information
ib-steffen committed Oct 20, 2018
1 parent 29bd89d commit a65392b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/github/trigger/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ def create_push(self, c, repository, branch, tag):
status_url])

build_id = self.create_build(commit_id, project_id)
self.create_job(c['id'], repository['clone_url'], build_id,
clone_url = repository['clone_url']

if repository['private']:
clone_url = repository['ssh_url']

self.create_job(c['id'], clone_url, build_id,
project_id, branch)

def handle_push(self, event):
Expand Down Expand Up @@ -393,8 +398,14 @@ def handle_pull_request(self, event):
return res(200, 'build already triggered')

build_id = self.create_build(commit_id, project_id)

clone_url = event['repository']['clone_url']

if event['repository']['private']:
clone_url = event['repository']['ssh_url']

self.create_job(event['pull_request']['head']['sha'],
event['pull_request']['head']['repo']['clone_url'],
clone_url,
build_id, project_id, branch, env=env, fork=is_fork)

self.conn.commit()
Expand Down
2 changes: 1 addition & 1 deletion src/job/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fi
if [ ! -z "$INFRABOX_GIT_PRIVATE_KEY" ]; then
echo "Setting private key"
eval `ssh-agent -s`
echo $INFRABOX_GIT_PRIVATE_KEY > ~/.ssh/id_rsa
echo "$INFRABOX_GIT_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "StrictHostKeyChecking no" > ~/.ssh/config
ssh-add ~/.ssh/id_rsa
Expand Down

0 comments on commit a65392b

Please sign in to comment.