
If you were logged in you would be able to see more operations.
|
|
|
QuickBuild
Created: 15/Jul/16 05:06 PM
Updated: 01/Dec/16 07:31 AM
|
|
Component/s: |
None
|
Affects Version/s: |
None
|
Fix Version/s: |
None
|
|
Original Estimate:
|
Unknown
|
Remaining Estimate:
|
Unknown
|
Time Spent:
|
Unknown
|
|
Currently for Git repositories, QuickBuild always checks out a detached head. I understand the purpose, to ensure the checked out state matches the pre-build snapshot. However not having a branch checked out is problematic for build tool plugins that find and record SCM information. It's pretty simple to check the requested branch's revision against the checkout revision and checkout the branch if same. Here is sample post-execute Groovy script that I tested on a checkout step
groovy:
import com.pmease.quickbuild.plugin.scm.git.GitCli;
def git = new GitCli(step.repository)
def shortBranch = step.repository.getActualBranch()
String branchRev = git.revision(shortBranch)
String revision = step.repository.getRevision()
logger.info("Requested branch '" + shortBranch + "' has revision '" + branchRev + "'")
logger.info("Build revision is " + revision)
if (branchRev.equals(revision)) {
logger.info("Checking out branch")
git.checkout(shortBranch)
}
Alternatively (and probably simpler) would be to 'checkout -f' the requested branch to the revision in the snapshot.
|
Description
|
Currently for Git repositories, QuickBuild always checks out a detached head. I understand the purpose, to ensure the checked out state matches the pre-build snapshot. However not having a branch checked out is problematic for build tool plugins that find and record SCM information. It's pretty simple to check the requested branch's revision against the checkout revision and checkout the branch if same. Here is sample post-execute Groovy script that I tested on a checkout step
groovy:
import com.pmease.quickbuild.plugin.scm.git.GitCli;
def git = new GitCli(step.repository)
def shortBranch = step.repository.getActualBranch()
String branchRev = git.revision(shortBranch)
String revision = step.repository.getRevision()
logger.info("Requested branch '" + shortBranch + "' has revision '" + branchRev + "'")
logger.info("Build revision is " + revision)
if (branchRev.equals(revision)) {
logger.info("Checking out branch")
git.checkout(shortBranch)
}
Alternatively (and probably simpler) would be to 'checkout -f' the requested branch to the revision in the snapshot. |
Show » |
|
git checkout <your branch>