Flutter - Include private repo from bitbucket for codemagic build - flutter

How would i include a private repo thats on bitbucket in my pubspec.yaml?
Locally with the code checked out we can add this to pubspec.yaml
sp_utilities:
path: ../../packages/sp-utilities
But this would fail if you build from a build server.
We tried adding it as follow to no avail
sp_utilities:
git:
url: https://xxx#bitbucket.org/xxx/xxx-utilities.git

From the Dart Documentation:
Even if the package repo is private, if you can connect to the repo using SSH, then you can depend on the package by using the repo’s SSH URL:
So the lines in the Pubspec.yaml should be as follow:
dependencies:
kittens:
git: https://xxx#bitbucket.org/xxx/xxx-utilities.git
This however requires setting up a SSH Key for the authentication.
These steps can vary a little according to your system, and specific instructions can be found on the link above, but the tasks roughly are the same:
Creating a pair o SSH key files using the command ssh-keygen.
Adding this files to the SSH-Agent so you don't have to type your password everytime. The command related to this is ssh-add.
Log in to your Bitbucket account and add the public key file contents there. That option should be inside Personal settings > Account Settings > SSH Keys.
Confirm the operation on your e-mail.
You can confirm you have made all the steps above correctly by trying to SSH directly to it:
ssh -T git#bitbucket.org

Related

CircleCI failing to access private repository

We have a Flutter app which uses a private repository as a dependency.
The SSH key has been added to CircleCI, and the remote access to the repository works just fine locally using this same key.
The config has been added to the .circleci/config.yml:
- add_ssh_keys:
fingerprints:
- "84:1a:so:me:ke:y:14:31:0f"
But CircleCI keeps failing to access the private dependency repo , giving the following error:
" Running "flutter pub get" in project... Git error. Command: git clone --mirror git#bitbucket.org:our_account/priv_repo.git /home/circleci/development/flutter/.pub-cache/git/cache/priv_repo-3456accd54b38ec5b3820944f77e90ce2ddc9887
stdout: stderr: Cloning into bare repository
'/home/circleci/development/flutter/.pub-cache/git/cache/priv_repo-3456accd54b38ec5b3820944f77e90ce2ddc9887'...
Warning: Permanently added the RSA host key for IP address
'18.205.93.1' to the list of known hosts. Unauthorized fatal: Could
not read from remote repository.
Please make sure you have the correct access rights and the repository
exists. exit code: 128 "
Has anyone successfully created a CircleCI deployment which includes a private repo dependency?
What might possibly be missing to cause this issue?
OK - there were a couple of things I had wrong,
The main one was that I had the add_ssh_keys line in the wrong place.
It really needs to be the first step, or at least be before the flutter/install_sdk_and_pub step.
eg. This works (but if the add_ssh_keys step was at the bottom of the list of 4 steps here then it fails):
steps:
- add_ssh_keys:
fingerprints:
- "84:1a:so:me:ke:y:14:31:0f"
- checkout
- aws-cli/setup:
profile-name: example
- flutter/install_sdk_and_pub:
flutter_version: 2.5.3
In addition to that it is worth noting that I added my SSH key as an "Additional SSH Keys" type key (adding a "User Key" broke the deploy) (that is under Project Settings > SSH Keys),
and I set the Hostname for the key to "bitbucket.org".
So CircleCI is now successfully pulling in my private repo dependency.
It is failing on versioning mismatch stuff, but that is another issue, and shall be solved at another time.
I want to clarify some things first.
The main one was that I had the add_ssh_keys line in the wrong place.
It really needs to be the first step, or at least be before the flutter/install_sdk_and_pub step.
Yes, it's because each step runs in a different session, so they don't share the configs from each other. Your ssh-key only works because the environment variables defined on the Project Settings, are used across all the steps.
eg. This works (but if the add_ssh_keys step was at the bottom of the list of 4 steps here then it fails):
Yes, and if you want to use this fingerprint in another step, you need to paste it there too.
There are some things that you can do to fix your problem, you can leave the main ssh-key on the Project Settings and you can create an environment variable with the public key content (from another ssh-key).
After that, before using that second key, you need to run some commands like:
- run:
name: Step I'm using the second key
command: |
echo -e $MY_ENV_VAR | base64 -d > key
chmod 400 key
eval $(ssh-agent -s)
ssh-add key
git clone...
docker build...
Doing that, you will be able to clone the second repo.
Two things that worked for me:
Adding checkout step before updating the submodules
Adding the User public key(from CircleCI) to Bitbucket both repositories,the submodule repository and the parent repository that uses the submodule.
Checkout
As mentioned here https://circleci.com/docs/configuration-reference#checkout:
Note: CircleCI does not check out submodules. If your project requires submodules, add run steps with appropriate commands as shown in the following example:
- checkout
- run: git submodule sync
- run: git submodule update --init
User Key
The "User Key" public key is not added automatically to Bitbucket. Here is an explanation on how to add it https://circleci.com/docs/bitbucket-integration#create-a-bitbucket-user-key.
After you copy the key from the "Developer Tools" you need to add it to "Access keys" in Bitbucket.

How to use а private repository with VSCode?

A novice here, please type a small instruction describes how to use a private GitHub repo in VSCode
To configure a private repo, you first need to generate a public/private RSA key pair on your dev machine to be able to establish an ssh connection to your repo instead of an HTTP connection.
Just install Git for Windows in your development environment. During installation, please make sure that you have checked the option to include git bash, as you'll need it to create this key. Once installed, right click on your Windows user folder, select on Open git bash and then just run ssh-keygen (or if you are using Linux, you can just ssh-keygen) and go through the wizard.
This step will create a hidden .ssh folder that contains your public/private RSA key pair. Navigate to that folder.
The goal here with these keys is to configure your public key on GitHub. Open your id_rsa.pub file with notepad and copy its entire content. Then go to GitHub and under your user Settings > SSH keys just add a key and paste your entire public key plus an arbitrary name.
Now restart VS Code and press CTRL+ ' (Backtick) to open PowerShell and then run:
In case you haven't cloned your repo:
git clone git#github.com:{UserName}/{RepoName}.git
To Upload changes to your repo:
git add .
git commit -m "{Name for this commit}"
git push {Repo Origin name (default = Origin)} {Branch Name (Default = Master)}
Note. {} are for reference, do not include them in your commands.
VS Code has built-in support for Source Control, so if it is configured, VS Code will automatically detect changes and get them ready to commit with just a commit message and click. Also, there's a really good VS Core extension called GitLens. This can help you to 1-click push
That should do it. 😃
As of now (july 2019, not sure when this got added exactly) you can do this from within VSCode, just hit F1 in windows or ctrl+⇧+P (or ⌘+⇧+P on mac) to access the command palette of VSCode, then type or select Git: Clone and finally enter the URL of your repository, so something like https://github.com/MY_USERNAME/MY_PROJECT.git, finally choose the folder you want to use for your cloned repository (open the main folder that contains all your projects, no need to manually create a sub folder for the project itself, git will do this for you using the projects name)
To find your exact repository URL, open the projects github page and click on the green button on the top right that says "Clone or download", if you wonder if you should use HTTPS or SSH check out the github documentation
I had trouble with cloning a private repository from Github with VSCode. In my case the problem was that I followed Github docs instructions to generate SSH keys with Ed25519 algorithm and using these keys (id_ed25519.pub) with VScode and Github did not work for me.
I generated new keys with the RSA algorithm:
ssh-keygen -t rsa -b 4096 -C "your_email#example.com"
and after adding id_rsa.pub to my Github account settings VSCode started working with private repositories.
If Git is already installed
Copy the URL of your private repository
Go to the version control in VS Code
Click on clone repository (authentication required if not done already) and
Paste the copied URL in the edit text box as shown in the documentation.
i have same problem- but solution was simple:
Mistake was: in windows when you create a keys name should be "id_rsa" (windows cmd suggest rename yor keys).
if your key name is different simple rename private and public keys to "id_rsa" and "id_rsa.pub"
Then add keys via: ssh-add ~/.ssh/id_rsa (edit path if files in different).
Then add id_rsa.pub key to github profile settings(copy paste of content).
Now you can work with private repositories.
#Daniel summed it up but quick read for anyone who's having issues with generating ssh/adding it to github.
As #Kennet stated use ssh-keygen -t rsa -b 4096 -C "your_email#example.com" hit enter through, it will default to C:Users most likely.
Copy the ida_rsa.pub generated in github go to Setting -> Deploy keys (documentation I saw was outdated) and paste it in and name it ida_rsa.pub.
Note: Make sure to select "Allow write access" otherwise your pushes will be denied
If you want multiple ssh keys, this document explains how

Import existing file folder to IBM Watson Application

I have downloaded on my PC this IBM Watson project:
https://github.com/watson-developer-cloud/conversation-simple/
and following its tutorial I've uploaded it on my IBM dashboard.
The problem is that everytime I want to change somethink in the project I've to re-upload it with the command line command cf push.
When I go in the Toolchain section, I can't see all the files and their folders, but only create a new repository or clone it, but in both case I haven't resolved my problem.
How can I resolve this problem?
Try to use:
cf push APP_NAME
Obs.: cf push does not support incremental upload. It will simply push everything in the folder to the cloud.
If your node_modules in the folder which resulted in a large-size upload. Try to specify what to exclude in a .cfignore file.
Example .cfignore file contents:
tmp/
node_modules/
my_unnecessary_file.txt
When executing your next cf push for deploying the application it will omit the files and directories listed in your .cfignore file.
See more about CF PUSH.
See more deploy applications with CF CLI.
It doesn't change anything, because when you create a toolchain it ask you to select between:
- New
- Clone
- Fork
and I tried all these options but going in the web eclipse editor files don't appear.
This s the git repository of my app:
https://git.ng.bluemix.net/consultagiovanilepolizzi/official-app2
How can I import with Git an existing project in my computer to edit it with toolchain?
As it seems that you are working with the Continuous delivery, instead of uploading your app using cf push, you are going to use the toochain.
The fist step is to use the git repository, you need to create a ssh key or an access token, if you prefer to connect through https, the access token can be created in the Bluemix git, going into the settings of your user, then Access Tokens
After that, you can push your app to the repository using a git tool, the user name will be your IBM account, and the password your token.
In the delivery pipeline, the build stage checks you repository for new commits into the master, by default, and start a new build, sending to the deploy if successful.
Those links below can give you more details
Using git Repos
Setting up local clients
Delivery Pipeline

How to link Smartgit to GitHub

I have a public GitHub account for the last year or so. Yesterday I installed SmartGit on my Windows 7 PC. SmartGit works fine locally but I'd like to push to a remote repo on GitHub.
When I look at SmartGit -> Preferences -> Authentication I have selected to use SmartGit as SSH Client. The 'Known Credentials' area is empty.
Under Hosting Providers I have added my github account [username+password] and Clicking on 'Login at GitHub...' it opens the browser and I am logged in successfully.
I would have assumed there would be something populating the Known Credentials area? I tried in vain in see if I had some key-pair stored somewhere that SmartGit could use. Eventually I downloaded PuttyGen and created a pair of keys. I gave them silly names to begin with but after some reading renamed them to *id_rsa* and "id_rsa.pub" and dropped them into my c:\users\MYNAME.ssh directory.
Still no sign of any credentials in SmartGit.
When I run the 'Remote -> Manage Remotes -> Add I enter the git name (based on the link I get from the github repo. I get the "Provide Credentials for authenticating to the SSH Server 'github.com' as user 'git'. The dialog box has pre-populated the Private Key File with the id_rsa I dropped into the .ss directory.
I even went onto github and added this key to the list of SSH keys. Still no joy.
Anyone any suggestions ?
Assuming it works similar on github and bitbucket.
Today I got Smartgit 3.0.10 running with bitbucket by the following steps:
To upload local code
1) Created the repository in bitbucket manually through the website
2) Add your ssh key to the website ( PuttyGen > Conversions > Export OpenSSH )
3) In your local repos check the contents of reposDir.hg\hgrc , should look like
[paths]
default = ssh://hg#bitbucket.org/user123/reposXYZ
if not change it manually. You can also clone your empty repos and the check in the
local copy for this line.
Restart SmartGit and you should be able to push and pull.
If you use the "HTTPS clone URL" on github, it makes a link that requires no SSH keys.
These 2 articles explain it:
https://help.github.com/articles/which-remote-url-should-i-use
https://help.github.com/articles/generating-ssh-keys

Github Integration with Hudson CI

What I have done so far:
Deployed a tomcat6.0 server to c:\www
Downloaded and deployed the Hudson.war in the c:\www\webapps folder
Installed the Github plugin
Created a private repository on Github
On the server, with hudson installed, generated ssh keys.
Environment variable %HOME% is set to c:\Documents and settings[username] (there is a .ssh directory in there with the keys)
Environment variable %HUDSON_HOME% set to c:\www\webapps\hudson
In hudson I have the following configurations:
Github Project: https://github.com/[my organization]/[project name]
Source Code Management: Git
URL of Repository: git#github.com:[my organization]/[project name].git
Branch specifier: **
Repository Browser: (Auto)
When I run a build, and click the console output link I see this --
Started by user anonymous
Checkout:workspace / C:\www\webapps\hudson\jobs\[project name] (git)\workspace - hudson.remoting.LocalChannel#2e8f6d20
Using strategy: Default
Checkout:workspace / C:\www\webapps\hudson\jobs\[project name] (git)\workspace - hudson.remoting.LocalChannel#2e8f6d20
Fetching changes from the remote Git repository
Fetching upstream changes from git#github.com:[organization name]/[project name].git
... at which point it hangs. When I cancel the build, the following are added --
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
ERROR: (Underlying report) : Error performing command: git.exe fetch -t git#github.com:[organization name]/[project name].git +refs/heads/*:refs/remotes/origin/*
null
ERROR: Could not fetch from any repository
FATAL: Could not fetch from any repository
hudson.plugins.git.GitException: Could not fetch from any repository
at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:796)
at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:754)
at hudson.FilePath.act(FilePath.java:756)
at hudson.FilePath.act(FilePath.java:738)
at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:754)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:540)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1180)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:506)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:422)
at hudson.model.Run.run(Run.java:1362)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:145)
First off, since you are starting off with a new CI instance, I would highly recommend that you install the Jenkins fork instead (since it is actively maintained by most of the original developers of Hudson).
Secondly, install the DumpInfo Wrapper plugin and re-run the build again. This plugin prints the system properties and environmental variables in effect during the build and allows you to verify them.
Update:
That plugin should log the system properties and environmental variables, I am surprised you do not see them. As for the passphrase, I suggest you generate a separate private key (from your existing pair) that is not passphrase-protected instead, otherwise you may need to consider the solution offered for: Why git can't remember my passphrase under Windows. I have verified that it works (when I set up my own CI on windows) but I don't feel it is worth the trouble (there are other nuances including installing and running the tomcat instance as the currently logged in user, and NOT as local service, so that pageant will work with it properly), hence I would recommend the first option.
In my case it turned out to be the problem with Git client: I was using v1.6.0 which was triggering
fatal: https://github.com/dmak/jaxb-xew-plugin.git/info/refs download error - The requested URL returned error: 403
error message in Hudson. First it looked like this issue, but strace analysis of git run shown that is was Nginx WebServer (which GitHub is running on) returning 403, not the proxy.
When I've updated to v1.7.3 the problem was gone. So general advise: don't use old clients with GitHub.
P.S. I have tested the cloning both with "Branch Specifier (blank for default): origin/master" in Hudson job configuration and also with blank (default): in both cases Git was able to discover the master branch (origin/master) correctly and used it for cloning.