From 381aa8b9029aff19545af92a01541afca6d86843 Mon Sep 17 00:00:00 2001 From: athmika Date: Mon, 28 Mar 2022 16:00:48 +0530 Subject: [PATCH] Store private key as env variable and ssh-add - contents of ~/.ssh/gerrit in jenkins is now stored as an environment variable ID_RSA --- bin/docker-execute | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/docker-execute b/bin/docker-execute index d3a1c77209..3e324bf54f 100755 --- a/bin/docker-execute +++ b/bin/docker-execute @@ -229,21 +229,24 @@ docker run --privileged=true -dit \ -e PACKAGE_NAME=$PACKAGE_NAME \ -e REPO_NAME=$REPO_NAME \ -e SSH_KEY=$SSH_KEY \ + -e PRIV_KEY=$(cat ${HOME}/.ssh/gerrit) \ --env "LOCAL_GITHUB_ACCESS_TOKEN=$LOCAL_GITHUB_ACCESS_TOKEN" \ "${DOCKER_OPTS[@]}" \ --cap-add=SYS_PTRACE \ "$IMAGE_NAME" "${CONTAINER_ARGS[@]}" #docker exec ${CONTAINER_NAME} bash -c 'echo $SSH_AUTH_SOCK' +echo "Docker exec:-" #docker exec ${CONTAINER_NAME} bash -c 'chmod dependabot:dependabot /home/dependabot/dependabot-core/tmp'; -docker exec -u 0 ${CONTAINER_NAME} bash -c 'ls -ald /home/dependabot/dependabot-core/tmp; +docker exec ${CONTAINER_NAME} bash -c 'ls -ald /home/dependabot/dependabot-core/tmp; ls -ald /home/dependabot/dependabot-core; echo "UID: $(id -u)" echo "GID: $(id -g)" whoami; ls -la /home/dependabot/.ssh; eval $(ssh-agent -s); +ssh-add $PRIV_KEY; ssh-add /home/dependabot/.ssh/$(echo $(cat /home/dependabot/.ssh/config | grep IdentityFile) | cut -d " " -f 2 | cut -d "/" -f 3); for c in $(ssh -p 29418 -o "StrictHostKeyChecking no" jenkins@gerrit.helpshift.com gerrit query --current-patch-set project:${REPO_NAME} branch:feature/dependabot | grep revision | tr -s " " | cut -d " " -f 3); \