Skip to content

Commit a65392b

Browse files
committed
use ssh_url for private github repos
1 parent 29bd89d commit a65392b

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/github/trigger/trigger.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,12 @@ def create_push(self, c, repository, branch, tag):
223223
status_url])
224224

225225
build_id = self.create_build(commit_id, project_id)
226-
self.create_job(c['id'], repository['clone_url'], build_id,
226+
clone_url = repository['clone_url']
227+
228+
if repository['private']:
229+
clone_url = repository['ssh_url']
230+
231+
self.create_job(c['id'], clone_url, build_id,
227232
project_id, branch)
228233

229234
def handle_push(self, event):
@@ -393,8 +398,14 @@ def handle_pull_request(self, event):
393398
return res(200, 'build already triggered')
394399

395400
build_id = self.create_build(commit_id, project_id)
401+
402+
clone_url = event['repository']['clone_url']
403+
404+
if event['repository']['private']:
405+
clone_url = event['repository']['ssh_url']
406+
396407
self.create_job(event['pull_request']['head']['sha'],
397-
event['pull_request']['head']['repo']['clone_url'],
408+
clone_url,
398409
build_id, project_id, branch, env=env, fork=is_fork)
399410

400411
self.conn.commit()

src/job/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fi
3434
if [ ! -z "$INFRABOX_GIT_PRIVATE_KEY" ]; then
3535
echo "Setting private key"
3636
eval `ssh-agent -s`
37-
echo $INFRABOX_GIT_PRIVATE_KEY > ~/.ssh/id_rsa
37+
echo "$INFRABOX_GIT_PRIVATE_KEY" > ~/.ssh/id_rsa
3838
chmod 600 ~/.ssh/id_rsa
3939
echo "StrictHostKeyChecking no" > ~/.ssh/config
4040
ssh-add ~/.ssh/id_rsa

0 commit comments

Comments
 (0)