Install plugin from private Git repository?

(Muthukkumar) #1

Hi All,
I have read all the commands in Install Plugins in Discourse. But I didn’t get the result what I am looking for. I am having one issue while cloning the plugin form Azure repo. Could some one help me to fix that. Below is my app.yml file:

run:
  - exec: echo "Beginning of custom commands"
  - exec: cd /var/www/discourse && sudo -u discourse bundle install --deployment --without test --without development
  - exec: mkdir /root/.ssh/
  - exec: touch /root/.ssh/known_hosts
  - exec: ssh-keyscan -t rsa azure.microsoft.com > /root/.ssh/known_hosts
  - exec: echo "Host azure.microsoft.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
    #- exec: mkdir -p /root/.ssh
  - file:
      path: /root/.ssh/id_rsa
      chmod: 600
      contents: |
        -----BEGIN RSA PRIVATE KEY-----
        Proc-Type: 4,ENCRYPTED
        DEK-Info: AES-128-CBC,19EA4589000FE19E7F44F2E86FDA3990
        LVu2mQfE468ewQs4dbNN/VQ0ocVx
        7bxXEvdz6VDgkanHKDsadfasgqw3tfy+1Mh4VtW7iHbOORE.. etc...
		-----END RSA PRIVATE KEY-----
  - file:
      path: /root/.ssh/id_rsa.pub
      chmod: 600
      contents: ssh-rsa AAAAB3NzaC1ycadfasdfsalkfffjsggsadfdfsf My@abc-31.local
  - exec: cd $home/plugins && git clone yec-addx@vs-ssh.visualsdio.com:url-for-private-plugin
  - exec: cd $home && sudo -E -u discourse bundle exec rake db:migrate
  - exec: cd $home && rm -fr tmp/cache
  - exec: cd $home &&  sudo -E -u discourse bundle exec rake assets:precompile
  - exec: rm /root/.ssh/id_rsa
  - exec: rm /root/.ssh/id_rsa.pub
  - exec: echo "End of custom commands"

Error After ./launcher rebuild app
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse/plugins && git clone yec-addx@vs-ssh.visudio.com:url-for-private-plugin failed with return #<Process::Status: pid 4231 exit 128>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params "cd $home/plugins && git clone yec-addx@vs-ssh.visudio.com:url-for-private-plugin"

Could some one me to fix this issue. Many thanks in advance…

0 Likes

Install Plugins in Discourse
#2

If you go to the plugins directory and run:

git clone yec-addx@vs-ssh.visudio.com:url-for-private-plugin

what do you get?

Specifically url-for-private-plugin doesn’t look like a valid path?

See:

https://git-scm.com/docs/git-clone#_git_urls_a_id_urls_a

1 Like

(Muthukkumar) #3

Hi Thanks for the response, that is my sample URL. I can able to clone the plugin in my VM, since I am having ssh public key in VM. But I am not able to clone the repo inside the container while run the app.yml.

If I clone it inside the plugin I am getting below details:

Cloning into ‘Community%20Plugins’…
The authenticity of host ‘vs-ssh.visualstudio.com (40.81.25.218)’ can’t be established.
RSA key fingerprint is SHA256:ohD8VZEXGWo6Ez8GSEJQ9WpafgLFsOfLOtGGQCQo6Og.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘vs-ssh.visualstudio.com,40.81.25.218’ (RSA) to the list of known hosts.
yec-addx@vs-ssh.visualstudio.com’s password:

Even if I give correct password its not taking.
Could you please suggest to fix this issue.

1 Like

#4

Got it. So this is a private repo? Instead of username/password is there any support for access tokens?

e.g. for Github:

https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line

Then you can use that in your git clone command like:

git clone https://my-access-token-code@github.com/blah/blah

This avoids any prompt.

Not sure if that’s supported in your repository though.

1 Like

(Jay Pfaffman) #5

Are you saying that the ssh private key that you are using requires a password? They won’t work.

You’ll need an ssh key in the container they allows downloads without a password. The ssh keys must be in place before the container tries to download it.

3 Likes

(Muthukkumar) #6

Hi @pfaffman yes its worked. when I passed the ssh keys in app.yml I was not able to clone the plugin. But inside the plugin folder I can able to clone it.
As per @pfaffman suggestion copied the ssh keys in volume: host/ guest: command. Then I can able to clone my private repo.
Thanks a lot for the supports.

2 Likes