This is the second part of blogpost about integration between issue tracking system, CI server and VCS. Part 1 is about components setup. Part 3 is about resolving an issue.
1. Use case scenario: create a project
Use Case Name: Start a project
1.1. Create project and repo in Stash
Then create a repo in this new project. Let’s give it the same name as for the whole project.
The new repo address has the following format:
<stash-tcp> is 7990. Note the last number!
<ssh-stash-tcp> is 7999. Note the last number!
In our particular case:
Note that we use git as a login name in ssh variant. Real login name is not needed because of authentication with SSH keys pair.
1.2. Import existing code to Stash
In local project folder do the following command:
git init git add --all git commit -m "Initial Commit" git remote add origin ssh://email@example.com:7999/math/math.git git push origin master
Or use any Git gui for this.
C:\math>git init Initialized empty Git repository in C:/inetpub/wwwroot/php/math/.git/ C:\math>git add --all C:\math>git commit -m "Initial Commit" [master (root-commit) 9dcff89] Initial Commit 8 files changed, 277 insertions(+) .... C:\math>git remote add origin ssh://firstname.lastname@example.org:7999/math/math.git C:\math>git push origin master Counting objects: 11, done. Delta compression using up to 8 threads. Compressing objects: 100% (11/11), done. Writing objects: 100% (11/11), 3.23 KiB, done. Total 11 (delta 1), reused 0 (delta 0) To ssh://email@example.com:7999/math/math.git * [new branch] master -> master
1.3. Create project in JIRA
Now let’s go to JIRA. We can use an Atlassian-products-menu in the upper-right corner to switch between programs.
Note that JIRA user must be a member of administrator group in order to be able to create a new project.
Its is better to name the new project with the same name as in Stash just to keep it in order (there is no direct binding by project name).
Choose the type of the project the fits our needs best.
Let’s check that Stash is ready for cooperation with JIRA. Go to project administration page and check that Stash is linked as a development tool.
1.4 Create build in TeamCity
Create a new project in TeamCity. Note that user must be a member of a group with administrative privileges in order to create new projects and builds.
Go to Administration menu and choose Project. Press [+Create project] button.
Let’s name the new project with same name as in Stash.
Now we need a build configuration for the newly create project. Go to Administration->[Math project] edit->press Create build configuration button.
I prefer to name the build after branch it will checkout sources from. Then press button [VCS settings].
Leave VCS checkout mode “Automatically on server” if you use authentication with SSH-keys. Then press button [+ Create and attach a new VCS root].
Now create and attach VCS root. Set git as VCS type. Set correct address for git repo. It will be
ssh://firstname.lastname@example.org:7999/math/math.git in our case. Locate a private key in the TeamCity server. TeamCity should have it’s own key to access Stash. Test connection and save.
Now configure build tasks and a VCS build trigger.
And now we are ready to run the build and watch the results!