How to get old version of project code base from jenkins - jenkins

My current project vesrion is 1.52, but got issue in 1.48 version, need that codebase(1.48) from jenkins because in github we have only master branch no other brancehs. Any possible way to get it from jenkins. Thanking you advancly.

The codebase is still in the GitHub repo, unless you rewrote the history with a git rebase + git pushed force on the master branch.
That said, the best thing you can do is to locate the commit on which your project version 1.48 is based, review if you have tags and releases in your GitHub repo, that will be the ideal scenario, to just checkout your repo to the release tag to get the desired code version (otherwise look for the commit messages).
In regards looking for the code base in Jenkins, I won't count with that option too much, aside of being way more complicated in comparison with the git repo inspection, it depends mainly of the job configuration setup:
How is the Log Rotation Strategy configured by means of days to keep
builds and Max # of builds to keep.
If you keep or delete the workspace.
If the build was run on the master itself or in a slave.
If you saved not only the artifacts but also the git repo outside the
workspace with the post build action archive artifacts...
You can either browse the workspace of the node where the build for the release 1.48 was made if it still exists, or look inside the builds folder for the archived artifacts inside '$JENKINS_HOME/jobs/YOURJOB/builds'

Related

TFS (CI) - Only one branch has just been check-in/pushed to be built

I'm trying to deploy a Continuous Integration server where I work.
We used TFVC with the branch to release strategy, but we are having difficulty with something that should be trivial.
We only need the build on the branch that was checked in.
Is it possible to do this without having to change the build definition every time a new branch is created?
I do not want to map the entire folder structure of the repository. Imagine having 10 branches and every check-in, build all? Does not make sense!
Anyone have any idea how to do it?
The CI build for TFVC can’t map and just build target branch like build for Git.
There are some workarounds:
Clone a build definition and change source mapping, Path filters of triggers for each branch.
Add a PowerShell step/task to get recent check-in change by calling get changesets Rest API, then store the related solution/project files in a variable by using Logging Commands, then build these solutions/projects

How to show git diff in Jenkins

I have a build job in Jenkins, which is based on a git project.
Looking at the changes page for each build, I can see the commits that are new to this version, who contributed them, and the list of files modified.
What I'm missing is the option to see the actual diff - what lines of code were changed.
How can this be achieved?
I'm using a local git repo hosted on the same PC as the jenkins server
You can use Last Changes Plugin to accomplish that.
Just install it and make sure to choose from Post-build Actions drop down menu the option Publish Last Changes.

Working with multiple TFS branches in Teamcity. How?

We are using TFS2010 for source control and TeamCity 8.x for CI. In our project we have Main branch for releases and bug-fixes and Dev for most of the development. Build steps for both branches are identical. and we have a few build configurations to go through:
I can't seem to make TeamCity to do checkout on a single branch and run build only on the branch that was checked-in to.
First attempt: I've added a VCS Root to point to $/Root that contains both Main and Dev branches and created checkout rules:
First checkin to Main works fine. Checkin to Dev after fails like this:
where DoNotExportAttribute is the file that was modified in the Dev branch. Even if I have
checkbox against "Clean all files in the checkout directory before the build".
My second attempt was to add both of the branches as VCS roots:
But this caused checkout of both branches into the same directory and whatever was checkout first was overwritten by second branch.
Is there a remedy for our case without creating separate configurations for every branch? (we started from config-per-branch, but that proven to be maintenance heavy for the number of steps we do in build)
If I understand correctly, you're trying to use a single TeamCity project for both your main and your branch builds. I would not recommend doing that. By re-using the same project for both your main and your branch builds, you will be sharing version numbers between two different beasts. Version 1.1.4 of the build might be a main build while version 1.1.5 might be a branch build.
By looking at the artifacts created by the build, it will also be difficult to identify which source code was the one selected and included into that artifact. Is the executable a main or a branch executable?
The way we solved the main vs branch problem was by creating a "template" project which contains all our build configurations (each one set up as a Build Configuration Template so they can all be changed in a single location) for building our software. Both the main line and the branch projects are created by copying this "template" project and setting the VCS root to the appropriate directory location.
We run five build agents and each build takes a fair amount of time. Having individual projects for each branch allows us to run builds in parallel if the main and any of the branches happen to have been modified at the same time whereas with one single project, the builds would be done serially.
Hope this helps.

Integrate crucible with tfs

I use TFS with Jira to managment my team tasks.
I want to integrate a Code Review tool at development process.
When i try to use crucible i reveal that it not support TFS.
I want to know if , there is a good and credible solution for this ,to enable me use crucible with TFS.
additional , if there are another suggests for code reiview tool for VS and JIRA.
Thank!
Some time ago we decided to run Crucible on our project. Our project uses TFS 2012. We use one branch in TFS called 'dev' as a trunk, i.e. branch where developers make commits and where raw code located. Second branch where release code located called 'main'
Our workflow for peer review was:
Make some changes and shelve code
Send email to reviewer
Reviewer doing review in some custom tool and send email with notification that he is done
Commit code into 'dev' branch on TFS
Wait while build-server makes successful build
Commit to 'main' branch where production code resides
Our goal was to improve step 2 and 3. Crucible is great tool, but it doesn't support TFS out of the box, thus we decided to use some TFS bridge. Actually, there are two main options either using tfs->svn or tfs->git. Finally, we decided to use tfs->git bridge, because creating branches in git extremely cheap and it might have been helpful (it did), because we was thinking use branches in git for out shelvesets in TFS. Finally we made our mind to use git.
So far I know only 2 options to convert TFS into git:
git tf - this one works on Linux and recommended by Microsoft
git tfs - this one works only under Windows, but we choose this one, because of large set of commands
We need to convert TFS branch into Git repo and maintain our git repository in fresh state. We don't work with git to push new changes back into TFS, we need git repo only for Crucible.
There are steps we made to achieve the goal:
1. Firstly, we cloned our TFS "dev" branch into "dev" repo. We needed only this one branch, and we haven't any back merges from "main" branch. We have tried to do this with clone command, but without any luck:
git tfs clone http://tfs:8080/tfs/DefaultCollection $/SOME_PATH/dev
This command cloning full history from TFS, but it seems our TFS branch quite large and at some time git-tfs crashed with System.OutOfMemoryException exception. Another time, we failed with exception that max limit of path was exceeded, we found workaround by mapping workspace dir into as short path as possible as follows:
git config --global git-tfs.workspace-dir e:\ws
When we failed with clone command, we went to use quick-clone command. This one cloning starting from any time in history, from any changeset.
git tfs quick-clone -c545532 http://tfs:8080/tfs/DefaultCollection $/SOME_PATH/dev
Option -c545532 here is the number of changeset to starting copying from. Once per year we update all our source files with new header, thus we just to copy from beginning of current year. In that way we should have all necessary history to make branches from shelvesets.
If you hadn't used -c argument here, you would have haven't any history at all, because quick-clone copies just history if you asking for it.
Once repository was cloned, we had written "script" and put it into task scheduler to run every 5 min. What script is doing is just checking for new commits in TFS and creates new branches on our git repository. Again, we use git-tfs here. To get all new commits we call pull command:
git tfs pull
To unshelve TFS shelveset into particular git branch we use unshelve command:
git tfs unshelve -user=TFSDOMAIN\Username "Shelveset Name Here" Branch_Shelveset_Name_Here
This last command creates branch 'Branch_Shelveset_Name_Here' in git from shelveset 'Shelveset Name Here' in TFS. A shelveset's name can contains spaces and some escape chars, so our "script" clean up such cases. As I said, creating branches very cheap on git, thus we haven't any problems with this. If something was pushed into git repo we call crucible API to refresh it.
BTW: To make git repo visible in network I just installed SCM-Server. Crucible was installed and configured to use our domain username/password, thus we get email notification as well. As result we drastically improved step 2 and 3 from our workflow and it works for few months and we are happy with it.
Our workflow became:
Make some changes and shelve code
Wait for our shelveset in crucible (about 6-8 min), create review
Reviewer doing review in crucible
Commit code into 'dev' branch on TFS
Wait while build-server makes successful build
Commit to 'main' branch where production code resides
While working with this I noticed few issues:
Issue1: If you added new file into project and shelved it, you would not see it in git repo, because git-tfs can't find parent commit for it. I'm not sure is it bug of this tool or not, but simplest workaround for this, is having at least one file in shelveset with existing parent. For example, you have added 2 new files and want to send it for review. Instead of creating shelveset with these files, just touch any file which already in git repo (make it pending in Visual Studio), finally you will be able create shelveset with three files (2 new files [add] and 1 for edit [edit]). In that case everything works and git-tfs can unshelve TFS' shelveset into git branch., i.e. we can see it in crucible.
Issue2: One day our HEAD in git repo became detached from "master" branch. Once that happened crucible didn't see new changesets. I have fixed it with command:
git rebase HEAD master
I have created picture how this everything works on our project, may be it could be helpful:
You can integrate Mira and TFS with TaskTop and then use the code review tools built into Visual Studio.
Code Review added in Visual Studio 2012
TaskTop integration with TFS & Jira
These I think are your best options.

Remove Travis CI old builds

This is my first day using Travis CI. I made some mistakes, I've tried removing and adding the repository again, but Travis CI build history is still there, with broken links for old commits.
Any chance to remove those old builds?
You can use the travis command line tool
Login first using travis login then you can do the following
LAST_BUILD_NUMBER=68
for i in $(seq 1 $LAST_BUILD_NUMBER ); do travis logs $i --delete --force ; done
This will remove the "logs" so there's no information aside from the header and any confidential information will no longer be visible.
There's no way for the user to remove builds, but if you really want them removed I think your best bet is to email support (support#travis-ci.org) and ask them to remove it manually.
Per https://twitter.com/travisci/status/557932883571392512
Since at least 2015/01/21 you can now delete [the log] from the web UI:
As henrikhodne, build deletion is not possible.
From https://github.com/travis-ci/travis-ci/issues/877 (mirror) where the issue was raised:
Closing this issue for good, as this isn't on the roadmap for the near future. (Jul 23, 2015)
You can click on the Remove log button
Another way to PURGE EVERYTHING which results in:
removing all the build history from Travis CI
removing the repo from Travis CI
removing the repo data from GitHub (all issues, PRs, wiki, everything)
removing all the dangling commits from git push -f
First make sure you have screenshots/backups/... of all your settings in Travis and in remote repository + that you have a 1to1 mirror of your remote repository (meaning ALL your branches properly downloaded to the local repo). That should be possible just with git clone, git fetch and maybe even git checkout to each of the branches, so that you have all the history available locally (correct me if I forget some step).
Then you want to go to your remote server e.g. GitHub and delete the repository (Settings - Danger Zone - Delete this repository). All your issues, PRs, wikis, any settings are gone now. Then create the same-named repository on GitHub again (do NOT! initialize it with anything, no license, no readme, no nothing).
Now all the dangling commits which would be cleaned locally via git gc are gone from the remote repo (stealthy GitHub links begone!). Anything that should be the bare repo.git folder should be overwritten (unless GitHub isn't doing something silly).
Proceed and go to Travis CI profile:
https://travis-ci.org/profile/<username>
Press Sync account under My account and check the Travis repo. All the settings and build history should be gone now too.
Now either remove the GitHub repo and resync again or proceed with the restoring:
git push -u origin <branch name> # repeat for each branch
Go to your settings backups (e.g. screenshots) and set everything the way it was before.
I was able to wipe the Travis build history simply.
I'm logging into to travis-ci.org via my Github account.
I went into travis-ci-org, and hit the + to show all repositories:
Then I turned off Travis CI for the repo in question by flipping this toggle:
In Github, I renamed my repo.
Then I hit "Sync account" in the upper left.
For my final step, I flipped that toggle back on under the new repo name.
Voila - no Travis history. I triggered a build manually and now everything is clean and clear.

Resources