Пример #1
0
	def getAllArtifactVersions(self, strGroupID, strArtifactID):
		atVersions = []

		strPath = self.strUrlLuceneSearchGA % (strGroupID, strArtifactID)
		aucContent = self.tRestDriver.get(self.tServerBaseUrl, strPath)
		tSearchResult = XML(aucContent)

		# The search result must be complete.
		if tSearchResult.findtext('tooManyResults')!='false':
			raise Exception("Received a truncated search result!")
	
		# Loop over all results.
		for tNode in tSearchResult.findall('data/artifact'):
			strVersion = tNode.findtext('version')
			if isinstance(strVersion, basestring)==True:
				strVersion = strVersion.strip()
				if strVersion=='SNAPSHOT':
					tVersion = deploy_version.version(0, 0, 0)
				else:
					tVersion = deploy_version.version(strVersion)
				atVersions.append(tVersion)

		# Sort the versions.
		atVersions.sort()

		return atVersions
Пример #2
0
	def findSha1Artifacts(self, strFileName, strGroupID, strArtifactID):
		atVersions = []

		# Generate the SHA1 sum for the file.
		strFileSha1 = self.generate_sha1_from_file(strFileName)

		strPath = self.strUrlLuceneSearchSha1 % strFileSha1
		aucContent = self.tRestDriver.get(self.tServerBaseUrl, strPath)
		tSearchResult = XML(aucContent)

		# The search result must be complete.
		if tSearchResult.findtext('tooManyResults')!='false':
			raise Exception("Received a truncated search result!")
	
		# Loop over all results.
		for tNode in tSearchResult.findall('data/artifact'):
			strG = tNode.findtext('groupId')
			strA = tNode.findtext('artifactId')
			strVersion = tNode.findtext('version')

			if isinstance(strG, basestring)==True and isinstance(strA, basestring)==True and isinstance(strVersion, basestring)==True:
				strG = strG.strip()
				strA = strA.strip()
				strVersion = strVersion.strip()
				if strGroupID==strG and strArtifactID==strA:
					if strVersion=='SNAPSHOT':
						tVersion = deploy_version.version(0, 0, 0)
					else:
						tVersion = deploy_version.version(strVersion)
					atVersions.append(tVersion)

		atVersions.sort()

		return atVersions
Пример #3
0
    def getAllArtifactVersions(self, strGroupID, strArtifactID):
        atVersions = []

        strPath = self.strUrlLuceneSearchGA % (strGroupID, strArtifactID)
        aucContent = self.tRestDriver.get(self.tServerBaseUrl, strPath)
        tSearchResult = XML(aucContent)

        # The search result must be complete.
        if tSearchResult.findtext('tooManyResults') != 'false':
            raise Exception("Received a truncated search result!")

        # Loop over all results.
        for tNode in tSearchResult.findall('data/artifact'):
            strVersion = tNode.findtext('version')
            if isinstance(strVersion, basestring) == True:
                strVersion = strVersion.strip()
                if strVersion == 'SNAPSHOT':
                    tVersion = deploy_version.version(0, 0, 0)
                else:
                    tVersion = deploy_version.version(strVersion)
                atVersions.append(tVersion)

        # Sort the versions.
        atVersions.sort()

        return atVersions
Пример #4
0
	def filter_init_changed(self):
		tVersionSnapshot = deploy_version.version(0, 0, 0)
		for tNodeTarget in self.tXml.findall('Project/Server/Target'):
			bSelected = True
			# Loop over all versions.
			for tNodeVersion in tNodeTarget.findall('version'):
				tVersion = deploy_version.version(tNodeVersion.text)
				bMatch = self.to_bool(tNodeVersion.get('match'))
				if tVersion!=tVersionSnapshot and bMatch==True:
					bSelected = False
					break
			tNodeTarget.set('filter', bSelected)
Пример #5
0
    def deploy(self, tArtifact, strRepositoryRelease, strRepositorySnapshot):
        # Is this a snapshot release?
        bIsSnapshot = (tArtifact['deploy_as'] == deploy_version.version(
            0, 0, 0))

        # Get the version string.
        strGID = tArtifact['gid']
        strAID = tArtifact['aid']
        strPackaging = tArtifact['packaging']
        strVersion = str(tArtifact['deploy_as'])

        astrDeployPath = []
        # Add the path to the repositories.
        # NOTE: This is fixed for nexus.
        astrDeployPath = ['content', 'repositories']

        # Append the repository name.
        if bIsSnapshot == True:
            astrDeployPath.append(strRepositorySnapshot)
        else:
            astrDeployPath.append(strRepositoryRelease)

        # Generate the artifact specific part of the path.
        astrDeployPath.extend(strGID.split('.'))
        astrDeployPath.append(strAID)
        astrDeployPath.append(strVersion)

        strLocalPath_Artifact = tArtifact['file']

        strRemotePath_Base = '%s/%s-%s.' % ('/'.join(astrDeployPath), strAID,
                                            strVersion)

        strRemotePath_Artifact = strRemotePath_Base + strPackaging
        strRemotePath_ArtifactHash = strRemotePath_Artifact + '.sha1'
        strRemotePath_Pom = strRemotePath_Base + 'pom'
        strRemotePath_PomHash = strRemotePath_Pom + '.sha1'

        print '%s:' % strLocalPath_Artifact
        print '\t%s' % strRemotePath_Artifact
        print '\t%s' % strRemotePath_Pom

        strFileHash = self.generate_sha1_from_file(strLocalPath_Artifact)
        strPom = self.generate_pom(strGID, strAID, strPackaging, strPackaging)
        strPomHash = self.generate_sha1_from_string(strPom)

        # Upload the hash sum of the artifact.
        self.tRestDriver.put_string(self.tServerBaseUrl,
                                    strRemotePath_ArtifactHash, strFileHash)

        # Upload the artifact.
        self.tRestDriver.put_file(self.tServerBaseUrl, strRemotePath_Artifact,
                                  strLocalPath_Artifact)

        # Upload the hash sum of the POM.
        self.tRestDriver.put_string(self.tServerBaseUrl, strRemotePath_PomHash,
                                    strPomHash)

        # Upload the POM.
        self.tRestDriver.put_string(self.tServerBaseUrl, strRemotePath_Pom,
                                    strPom)
Пример #6
0
def parse_version(strArgument):
	# Is this one of the special keywords?
	if strArgument.upper() in ['MAJ', 'MIN', 'SNAPSHOT']:
		# Ok, this is one of the special names.
		strResult = strArgument.upper()
	else:
		strResult = str(deploy_version.version(strArgument))

	return strResult
Пример #7
0
	def read_target_node(self, tNode):
		aAttrib = dict({})
		strValue = tNode.get('file')
		if strValue==None:
			raise Exception('One of the Target nodes has no file attribute!')
		strFile = strValue.strip()
		if strFile=='':
			raise Exception('One of the Target nodes has an empty file attribute!')
		aAttrib['file'] = strFile

		strValue = tNode.get('selected', 'False')
		bSelected = self.to_bool(strValue.strip())
		aAttrib['selected'] = bSelected

		strValue = tNode.get('deploy_as', '0.0.0')
		strDeployAs = deploy_version.version(strValue.strip())
		aAttrib['deploy_as'] = strDeployAs

		strValue = tNode.findtext('ArtifactID')
		if strValue==None:
			raise Exception('One of the Target nodes has no ArtifactID child!')
		strArtifactID = strValue.strip()
		if strArtifactID=='':
			raise Exception('One of the Target nodes has an empty ArtifactID child!')
		aAttrib['aid'] = strArtifactID

		strValue = tNode.findtext('GroupID')
		if strValue==None:
			raise Exception('One of the Target nodes has no GroupID child!')
		strGroupID = strValue.strip()
		if strGroupID=='':
			raise Exception('One of the Target nodes has an empty GroupID child!')
		aAttrib['gid'] = strGroupID

		strValue = tNode.findtext('Packaging')
		if strValue==None:
			raise Exception('One of the Target nodes has no Packaging child!')
		strPackaging = strValue.strip()
		if strPackaging=='':
			raise Exception('One of the Target nodes has an empty Packaging child!')
		aAttrib['packaging'] = strPackaging

		# Read all versions.
		aVersions = dict({})
		for tVersionNode in tNode.findall('version'):
			strVersion = tVersionNode.text.strip()
			if strVersion=='':
				raise Exception('One of the Target nodes has an empty version child!')
			if strVersion in aVersions:
				raise Exception('Double version!')
			bMatch = self.to_bool(tVersionNode.get('match'))
			aVersions[strVersion] = bMatch
		aAttrib['versions'] = aVersions

		return aAttrib
Пример #8
0
	def deploy(self, tArtifact, strRepositoryRelease, strRepositorySnapshot):
		# Is this a snapshot release?
		bIsSnapshot = (tArtifact['deploy_as']==deploy_version.version(0, 0, 0))

		# Get the version string.
		strGID = tArtifact['gid']
		strAID = tArtifact['aid']
		strPackaging = tArtifact['packaging']
		strVersion = str(tArtifact['deploy_as'])

		astrDeployPath = []
		# Add the path to the repositories.
		# NOTE: This is fixed for nexus.
		astrDeployPath = ['content', 'repositories']

		# Append the repository name.
		if bIsSnapshot==True:
			astrDeployPath.append(strRepositorySnapshot)
		else:
			astrDeployPath.append(strRepositoryRelease)

		# Generate the artifact specific part of the path.
		astrDeployPath.extend(strGID.split('.'))
		astrDeployPath.append(strAID)
		astrDeployPath.append(strVersion)

		strLocalPath_Artifact = tArtifact['file']

		strRemotePath_Base = '%s/%s-%s.' % ('/'.join(astrDeployPath), strAID, strVersion)

		strRemotePath_Artifact     = strRemotePath_Base     + strPackaging
		strRemotePath_ArtifactHash = strRemotePath_Artifact + '.sha1'
		strRemotePath_Pom          = strRemotePath_Base     + 'pom'
		strRemotePath_PomHash      = strRemotePath_Pom      + '.sha1'

		print '%s:' % strLocalPath_Artifact
		print '\t%s' % strRemotePath_Artifact
		print '\t%s' % strRemotePath_Pom

		strFileHash = self.generate_sha1_from_file(strLocalPath_Artifact)
		strPom = self.generate_pom(strGID, strAID, strPackaging, strPackaging)
		strPomHash = self.generate_sha1_from_string(strPom)

		# Upload the hash sum of the artifact.
		self.tRestDriver.put_string(self.tServerBaseUrl, strRemotePath_ArtifactHash, strFileHash)

		# Upload the artifact.
		self.tRestDriver.put_file(self.tServerBaseUrl, strRemotePath_Artifact, strLocalPath_Artifact)

		# Upload the hash sum of the POM.
		self.tRestDriver.put_string(self.tServerBaseUrl, strRemotePath_PomHash, strPomHash)

		# Upload the POM.
		self.tRestDriver.put_string(self.tServerBaseUrl, strRemotePath_Pom, strPom)
Пример #9
0
    def findSha1Artifacts(self, strFileName, strGroupID, strArtifactID):
        atVersions = []

        # Generate the SHA1 sum for the file.
        strFileSha1 = self.generate_sha1_from_file(strFileName)

        strPath = self.strUrlLuceneSearchSha1 % strFileSha1
        aucContent = self.tRestDriver.get(self.tServerBaseUrl, strPath)
        tSearchResult = XML(aucContent)

        # The search result must be complete.
        if tSearchResult.findtext('tooManyResults') != 'false':
            raise Exception("Received a truncated search result!")

        # Loop over all results.
        for tNode in tSearchResult.findall('data/artifact'):
            strG = tNode.findtext('groupId')
            strA = tNode.findtext('artifactId')
            strVersion = tNode.findtext('version')

            if isinstance(strG, basestring) == True and isinstance(
                    strA, basestring) == True and isinstance(
                        strVersion, basestring) == True:
                strG = strG.strip()
                strA = strA.strip()
                strVersion = strVersion.strip()
                if strGroupID == strG and strArtifactID == strA:
                    if strVersion == 'SNAPSHOT':
                        tVersion = deploy_version.version(0, 0, 0)
                    else:
                        tVersion = deploy_version.version(strVersion)
                    atVersions.append(tVersion)

        atVersions.sort()

        return atVersions
Пример #10
0
	def artifacts_filter_apply(self, strDeployStrategy):
		# Loop over all artifacts.
		for tNodeTarget in self.tXml.findall('Project/Server/Target'):
			# Only consider selected items.
			if tNodeTarget.get('filter')==True:
				tArtifact = self.read_target_node(tNodeTarget)

				# This artifact will be deployed.
				tNodeTarget.set('selected', str(True))

				# Set the version.
				if strDeployStrategy=='MAJ':
					# Get the latest version.
					tDeployVersion = deploy_version.version(0, 0, 0)
					for strVersion in tArtifact['versions'].iterkeys():
						tVersion = deploy_version.version(strVersion)
						if tVersion>tDeployVersion:
							tDeployVersion = tVersion
					tDeployVersion.next_major()
				elif strDeployStrategy=='MIN':
					# Get the latest version.
					tDeployVersion = deploy_version.version(0, 0, 0)
					for strVersion in tArtifact['versions'].iterkeys():
						tVersion = deploy_version.version(strVersion)
						if tVersion>tDeployVersion:
							tDeployVersion = tVersion
					tDeployVersion.next_minor()
				elif strDeployStrategy=='SNAPSHOT':
					tDeployVersion = deploy_version.version(0, 0, 0)
				else:
					tDeployVersion = deploy_version.version(strVersion)

				tNodeTarget.set('deploy_as', str(tDeployVersion))

				# Processed.
				tNodeTarget.set('filter', False)