CONTROLLED DATA
Leidos Proprietary - US Citizens ONLY
The information contained herein is proprietary to Leidos, Inc. It may not be used, reproduced, disclosed, or exported without the written approval of Leidos.

The ECR is based on using the Git distributed version control system.  If you are already using git to manage your projects, then this process should make sense to you.  If you are not a git user, then hopefully you will find the instructions simple and easy to follow.

When you request the ability to share code on the ECR, you will be given an account and a project on Bitbucket.  For each project you want to share, you will create your own set of repositories.  If you are a git user, then you will create a repository using the same name as your current repository.  If you are not a git user, then you can name them however you want.

Then your project will be found on this page.

Once you have created your repository, follow the instructions below to add your code.

Oh, BTW - if you are only putting artifacts into an Artifactory project, you will still create a Repo to hold your documentation artifacts!

When your code is pushed up to Bitbucket, you will have complete control over when you provide updates, or when you receive updates from the code sharing community.

You will want to add your SSH Key to Bitbucket, so that you can use ssh:// instead of http:// for interacting with Bitbucket.

Git users

This is the simplest method.  Once your repo has been created, you will:

  • Add a remote
  • Push your branch to the remote
  • Add a community branch, and push that branch to the remote

Add a remote

This is the easy step, simply copy the clone url for your repo, from the SSH url provided after clicking Bitbucket "clone" button...

...and use the following command in your local repo:

git remote add ecr ssh://git@ecr.sdo.leidos.com:7998/<your project key>/<your repo name>.git

If, for some unlucky reason, you already have a remote named "ecr", you can call this new one whatever you want "fred" is perfectly fine.

Note, this will not affect your current project.  Remotes are local to you, and are not propagated back upstream to git servers.

Pushing your branch

When you are working with your repository, git knows about all the branches and tags that have ever been created for your project.  You may want to share the entire history of your code, and all the branches with the ECR, or you might just want to share a particular branch such as develop or master.

Lets assume that you are only sharing your master branch, then this is what you will need to do:

git checkout master
git push ecr (or fred) master

Lets say that you want to push your develop branch, and that branch is based on master - this is typical of projects using GitFlow style branching strategies.

You will want to push both your master and develop branch to the ECR - this will make it easy to keep things in sync, and will let ECR users make better use of your shared code.

git checkout master
git push ecr master
git checkout develop
git push ecr develop

If you want to push the whole kit and kaboodle, then you will do this. 

git checkout master
git push ecr --all
git push ecr --tags

Create and push a community branch

What is a community branch, and why do you want one?  For this and more, jump down to the bottom of the page and read the Branching Strategy Section.

Subversion, Mercurial,  CVS, Monotone, Bazaar, TFS, VSTS, ClearCase, Dimensions, PVCS, SourceSafe etc... users, that have access to Git

For you, non-git users, your path is not necessarily harder, its just a different path.  Hopefully it will be a smooth path. If not, you can always contact the SDO helpdesk.

Basic Steps:

  • Copy your source code to a new folder (just so that we don't pollute ClearCase with git stuff...
  • Change directories to your new folder
  • Create a .gitignore file, with the content below at the top level of your new folder
  • Follow the instructions on the Repository page in Bitbucket (I have reposted them below for convenience)
  • Configure Git for the first time
  • Set up your project
  • Push it to Bitbucket

Git Configure and Push

Assuming that you have created your copy of your source code, and created a .gitignore file, we will pick things up at the git config step.

If you have never used git before, you will want to add your email and user name to your global git config.

git config --global user.name "Last, First A. [US-US]"
git config --global user.email "First.A.Last@leidos.com"


Now you will initialize your new source folder as a git repo, add the ECR as your "origin", and push your code.  Note... Its important to add your .gitignore file, before this step, or you will end up with a bunch of junk in your repo.

cd existing-project
git init
git add --all
git commit -m "Initial Commit"
git remote add origin ssh://git@ecr.sdo.leidos.com:7998/<your project/<your repo>.git
git push -u origin master


.gitignore file

The following .gitignore file will help to keep things out of the repo, that should probably not be there. If you think you need to push a zip file up to git, then remove the *.zip entry.  Also if there are other things you don't want to push up to the repo, and then here. Eclipse build files, family pictures...

.gitignore
# Compiled source #

###################
*.com
*.class
*.dll
*.exe
*.o
*.so

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sqlite

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db


Users that have no access to Git.

If this is you - please contact the SDO helpdesk.  We will be glad to help you out.


Branching Strategy for ECR

If you have made it here, you are almost done.  It's time to create the "community" branch.  This branch serves a couple purposes.  It provides a place for the ECR team to add artifacts to your project, without you having to add those artifacts to your baseline project.  Lets say that you deliver your current repository to your customer.  There is probably no reason that you would want to deliver ECR documentation artifacts to your customer.  Using the "community" branch lets us create things for you, without perturbing your environment.

The second thing the community branch provides - if you want to receive changes or feedback from people using your code, they can make a branch from the community branch, and then make a "Pull Request" to submit potential changes that you might find interesting (bug fixes, performance enhancements, security enhancements etc.)

Of course, if you don't want to take back changes, thats up to you and you can turn off the ability for users to create Pull Requests on your code.

Ok, creating the community branch is pretty simple.  First thing you need to do is decide which branch you want the community branch to be derived from.  If you only have master, then no decision making for you.  If you use GitFlow, then you might want to create the community from develop, or some other branch.

Branch from master

git checkout master
git checkout -b community
git push ecr community

Branch from develop

git checkout develop
git checkout -b community develop
git push ecr community


Last Step

The last thing you will want to do, is to head back to Bitbucket, go to your repository, and set your Default Branch to "community".


Adding your SSH Key

If you already have an ssh key, then this part is easy.  If you don't know, its typically found in a "~/.ssh/id_rsa.pub" file.  If you don't have an id_rsa.pub file, or you don't have a .ssh folder at all, don't despair.  If you are on Windows, you will want to go out to google and search for creating a private and public key using Putty Key Gen.  If you are on a system with openssl, then you can follow these instructions.


Create your key:

ssh-keygen -t rsa -b 4096


When you are prompted for a name just accept the default id_rsa in the default location.  Enter a passphrase.

If this is your first ~/.ssh folder that has been created, you will want to make sure that the permissions are all correct.

chmod 700 ~/.ssh
chmod 644 ~/.ssh/id_rsa.pub
chmod 600 ~/.ssh/id_rsa

The permissions are not only good for security, but some applications won't work if the permissions are not correct!

Now get your public key, its the one ending in "pub"

pbcopy < ~/.ssh/id_rsa.pub
or
cat ~/.ssh/id_rsa.pub  (and then scoop up the data to be copied with your mouse and copy it to the clipboard)


Now head over to Bitbucket and go to your Account Settings.  Top right of page, click on your Avatar, and select Account Settings. 

Then click on SSH Keys, and then Add Key, Paste your clipboard, and save the key.

Last step... Make sure that your key is managed by your system... add it to the ssh-agent cache so you don't have to enter your passphrase all the time.

eval `ssh-agent`
ssh-add ~/.ssh/id_rsa

References