Example #1
0
  def constructPreBuiltHTMITFakeroot(self):
    """
    Construct fakeroot from prebuilt htm-it

    :returns: SHA of the products repo in the fakeroot
    :rtype: tuple
    """

    config = self.config
    logger = self.logger
    productsDirectory = self.productsDirectory
    logger.debug("Creating %s", productsDirectory)
    mkpath(productsDirectory)
    copy_tree(config.productsDir, productsDirectory)
    iteration = git.getCommitCount(productsDirectory, logger=logger)

    with changeToWorkingDir(productsDirectory):
      actualSHA = git.getCurrentSha(logger=logger)

    # Set extra python path
    self.setPythonPath()

    # Clean HTM-IT Scripts
    self.cleanScripts()

    # Purge anything not whitelisted
    self.purgeBlacklistedStuff()

    return (iteration, actualSHA)
Example #2
0
    def constructPreBuiltGrokFakeroot(self):
        """
    Construct fakeroot from prebuilt grok

    :returns: SHA of the products repo in the fakeroot
    :rtype: tuple
    """

        config = self.config
        logger = self.logger
        productsDirectory = self.productsDirectory
        logger.debug("Creating %s", productsDirectory)
        mkpath(productsDirectory)
        copy_tree(config.productsDir, productsDirectory)
        iteration = git.getCommitCount(productsDirectory)

        with changeToWorkingDir(productsDirectory):
            actualSHA = git.getCurrentSha()

        # Set extra python path
        self.setPythonPath()

        # Clean Grok Scripts
        self.cleanScripts()

        # Purge anything not whitelisted
        self.purgeBlacklistedStuff()

        return (iteration, actualSHA)
Example #3
0
def getBuildNumber():
  """
    :raises:
      infrastructure.utilities.exceptions.CommandFailedError if
        the workspace env variable isn't set and you are running from outside of
        a git repo or the git command to find your current root folder fails.

    :returns: The value of the `BUILD_NUMBER` environment variable if set, or
    the current commit SHA of the git repo if it's not set.
  """
  buildNumber = None
  if "BUILD_NUMBER" in os.environ:
    buildNumber = os.environ["BUILD_NUMBER"]
  else:
    buildNumber = getCurrentSha()
  return buildNumber
Example #4
0
def gitCloneIntoFakeroot(fakeroot,
                         installDirectory,
                         repoDirectory,
                         gitURL,
                         sha=None,
                         logger=None):
  """
  Clone a git repository into a specific path in a fakeroot

  @param fakeroot: path to the directory to use as the root of the RPM's
    install tree

  @param installDirectory: Where to put the new git clone

  @param repoDirectory: what to name the cloned directory

  @param gitURL: git URL used to clone

  @param sha (optional): SHA to checkout once we've cloned the repository

  @param logger - Optional logger object, will be used to output more
  debugging information.

  @returns the SHA of the resulting git clone. We may not have been invoked
  with a specific SHA (we normally build tip of master, for example), but we
  always want to include the exact SHA packaged in our RPM descriptions.
  """
  if logger:
    logger.debug("Prepping fakeroot in %s", fakeroot)
  installPath = "%s/%s" % (fakeroot, installDirectory)
  with changeToWorkingDir(installPath):
    if logger:
      logger.debug("Cloning %s into %s/%s/%s",
                   gitURL,
                   fakeroot,
                   installDirectory,
                   repoDirectory)
    git.clone(gitURL, directory=repoDirectory)
    workDirectory = "%s/%s/%s" % (fakeroot, installDirectory, repoDirectory)
    with changeToWorkingDir(workDirectory):
      if sha:
        git.resetHard()
        logger.debug("Checking out SHA %s in %s", sha, workDirectory)
        git.checkout(sha)
      else:
        logger.debug("No SHA specified, using head of master")
      return git.getCurrentSha()
Example #5
0
def gitCloneIntoFakeroot(fakeroot,
                         installDirectory,
                         repoDirectory,
                         gitURL,
                         sha=None,
                         logger=None):
  """
  Clone a git repository into a specific path in a fakeroot

  @param fakeroot: path to the directory to use as the root of the RPM's
    install tree

  @param installDirectory: Where to put the new git clone

  @param repoDirectory: what to name the cloned directory

  @param gitURL: git URL used to clone

  @param sha (optional): SHA to checkout once we've cloned the repository

  @param logger - Optional logger object, will be used to output more
  debugging information.

  @returns the SHA of the resulting git clone. We may not have been invoked
  with a specific SHA (we normally build tip of master, for example), but we
  always want to include the exact SHA packaged in our RPM descriptions.
  """
  if logger:
    logger.debug("Prepping fakeroot in %s", fakeroot)
  installPath = "%s/%s" % (fakeroot, installDirectory)
  with changeToWorkingDir(installPath):
    if logger:
      logger.debug("Cloning %s into %s/%s/%s",
                   gitURL,
                   fakeroot,
                   installDirectory,
                   repoDirectory)
    git.clone(gitURL, directory=repoDirectory)
    workDirectory = "%s/%s/%s" % (fakeroot, installDirectory, repoDirectory)
    with changeToWorkingDir(workDirectory):
      if sha:
        git.resetHard()
        logger.debug("Checking out SHA %s in %s", sha, workDirectory)
        git.checkout(sha)
      else:
        logger.debug("No SHA specified, using head of master")
      return git.getCurrentSha()
Example #6
0
def getBuildNumber(logger):
  """
    Return the build number from either the user specified env var BUILD_NUMBER
    or use the current SHA of the active repo.

    :param logger: logger for additional debug info

    :raises infrastructure.utilities.exceptions.CommandFailedError:
      if the workspace env variable isn't set and you are running from outside
      of a git repo or the git command to find your current root folder fails.

    :returns: The value of the `BUILD_NUMBER` environment variable if set, or
      the current commit SHA of the git repo if it's not set.
    :rtype: str
  """
  buildNumber = None
  if "BUILD_NUMBER" in os.environ:
    buildNumber = os.environ["BUILD_NUMBER"]
  else:
    buildNumber = getCurrentSha(logger=logger)
  return buildNumber
def getBuildNumber(logger):
  """
    Return the build number from either the user specified env var BUILD_NUMBER
    or use the current SHA of the active repo.

    :param logger: logger for additional debug info

    :raises infrastructure.utilities.exceptions.CommandFailedError:
      if the workspace env variable isn't set and you are running from outside
      of a git repo or the git command to find your current root folder fails.

    :returns: The value of the `BUILD_NUMBER` environment variable if set, or
      the current commit SHA of the git repo if it's not set.
    :rtype: str
  """
  buildNumber = None
  if "BUILD_NUMBER" in os.environ:
    buildNumber = os.environ["BUILD_NUMBER"]
  else:
    buildNumber = getCurrentSha(logger=logger)
  return buildNumber