0

If i have a version 1.1 and a version 1.2 of the same codebase. Can we pull both the versions in a single jenkins workspace?

B.T Anand
  • 549
  • 1
  • 13
  • 26
  • 1
    Sure. You can run any command within Jenkins. Can you elaborate on, how you relate this with [tag:devops]? – StephenKing Aug 02 '17 at 07:45
  • I had the same query, I was asked this question in a devops interview...I want to understand, what changes will it require in my job configuration so as to cater the above requirement? Thanks for your time on this. – B.T Anand Aug 02 '17 at 07:57
  • Possible duplicate of [Checkout multiple git repos into same Jenkins workspace](https://stackoverflow.com/questions/14843696/checkout-multiple-git-repos-into-same-jenkins-workspace) – Cédric Julien Aug 02 '17 at 08:03
  • Please read more about what DevOps actually is. – StephenKing Aug 02 '17 at 08:47
  • Why do you want to pull different versions of same codebase into a single workspace? What is the goal that you are trying to achieve by doing so? – ANIL Aug 04 '17 at 08:42
  • This was asked in one of the technical interviews for devops....I haven't come across this use case ever till date – B.T Anand Aug 04 '17 at 08:44
  • You should have asked the interviewer for what purpose he needs that to happen. Haha :) – ANIL Aug 04 '17 at 09:42

3 Answers3

2

You can keep two different versions of the same code base inside a Jenkins workspace.

Let's say you have multiple Tags for different versions of the code in your git repository like v1.0, v1.2, v1.3 and so on... then you can clone specific tags to different destinations inside the workspace.

  1. Inside the workspace create a directory with the specific version name: mkdir v1.0
  2. Now cd into the v1.0 directory and clone the specific tag into it: git clone -b v1.0 --depth 1 https://org.githost.com/project/repo.git
  3. Repeat step 1 and step 2, create a directory with another veriosn (ex: v1.2) and then cd into it and clone the specific version (v1.2) into it.

This way you can have multiple versions of the same codebase in a single Jenkins workspace. You can use a Jenkins job with tag number as a parameter to automate the whole thing.

ANIL
  • 2,542
  • 4
  • 25
  • 44
2

In Jenkins, it is possible in Source Code Management plugin to specify multiple repositories.

And there is an option Check out to a sub-directory in the Additional Behaviours.

0

This plugin should help you - https://wiki.jenkins.io/display/JENKINS/Multiple+SCMs+Plugin

Upen
  • 1,388
  • 1
  • 22
  • 49