forked from SoftwareAG/sagdevops-ci-assets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildRepo.xml
executable file
·90 lines (75 loc) · 3.95 KB
/
buildRepo.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?xml version="1.0"?>
<project name="Repo" basedir=".">
<condition property="useLocalRepository">
<equals arg1="${config.build.fbr.type}" arg2="local" />
</condition>
<condition property="useArtifactoryRepository">
<equals arg1="${config.build.fbr.type}" arg2="artifactory" />
</condition>
<target name="bda.repo.prepareFbrForDeployment" depends="bda.repo.prepareLocalFbrForDeployment, bda.repo.prepareArtifactoryFbrForDeployment">
<log msg="Using fbr repository of type '${config.build.fbr.type}'" />
</target>
<target name="bda.repo.prepareLocalFbrForDeployment" if="useLocalRepository" depends="">
<property name="fbrRepoDir" value="${buildOutputDir}" />
</target>
<target name="bda.repo.init">
<property name="moduleName" value="${bda.projectName}" />
<property name="artifactName" value="${moduleName}-${baseRevision}.zip" />
<property name="artifactAsZipPath" location="${config.tmpdir}/${artifactName}" />
<log msg="Init repo with parameters: moduleName='${moduleName}', artifactName='${artifactName}', artifactAsZipPath='${artifactAsZipPath}'" />
</target>
<target name="bda.repo.prepareArtifactoryFbrForDeployment" if="useArtifactoryRepository" depends="bda.repo.init">
<property name="unzipDir" location="${config.build.buildStorageDir}/${moduleName}-${baseRevision}" />
<antcall target="common.deldir">
<param name="dir" value="${unzipDir}" />
</antcall>
<antcall target="common.create_dir">
<param name="dir" value="${unzipDir}" />
</antcall>
<log msg="Unzipping artifact with name '${artifactName}' into directory '${unzipDir}'. Searching for zip in directory '${config.tmpdir}'." />
<unzip dest="${unzipDir}">
<fileset dir="${config.tmpdir}" includes="**/${artifactName}">
</fileset>
</unzip>
<property name="fbrRepoDir" value="${unzipDir}" />
</target>
<target name="bda.repo.prepareArtifactoryDownloadSpec" depends="bda.repo.init">
<antcall target="bda.repo.createArtifactFileSpec">
<param name="type" value="download" />
</antcall>
</target>
<target name="bda.repo.processBuildOutput" depends="bda.repo.processBuildOutputForArtifactory, bda.repo.processBuildOutputForLocalRepo">
<log msg="Post processing of build output finished" />
</target>
<target name="bda.repo.processBuildOutputForLocalRepo" if="useLocalRepository" depends="">
<log msg="Using local repository, no processing of build output at '${buildOutputDir}' necessary" />
</target>
<target name="bda.repo.processBuildOutputForArtifactory" if="useArtifactoryRepository" depends="bda.repo.init">
<log msg="Using Artifactory as repository, pushing contents from ${buildOutputDir} to configured Artifactory server" />
<antcall target="bda.repo.zipOutputDir" />
<antcall target="bda.repo.createArtifactFileSpec">
<param name="type" value="upload" />
</antcall>
</target>
<target name="bda.repo.zipOutputDir">
<log msg="Creating FBR zip ${artifactAsZipPath} from directory '${buildOutputDir}' " />
<zip destfile="${artifactAsZipPath}" basedir="${buildOutputDir}">
<fileset includes="**/*" dir="${buildOutputDir}">
</fileset>
</zip>
</target>
<target name="bda.repo.createArtifactFileSpec" if="bda.artifactoryFileSpecName">
<property name="groovyScript.CreateArtifactoryFileSpec" location="resources/scripts/ArtifactoryFileSpec.groovy" />
<log msg="Creating Artifactory file spec '${bda.artifactoryFileSpecName}' for ${type}" />
<groovy src="${groovyScript.CreateArtifactoryFileSpec}">
<arg line="-outputDir ${env.WORKSPACE}/" />
<arg line="-fileSpecName ${type}.${bda.artifactoryFileSpecName}" />
<arg line="-pathToFbrZip ${artifactAsZipPath}" />
<arg line="-org ${config.build.artifactory.path.org}" />
<arg line="-moduleName ${moduleName}" />
<arg line="-baseRevision ${baseRevision}" />
<arg line="-artifactoryRepository ${config.build.artifactory.repository}" />
<arg line="-type ${type}" />
</groovy>
</target>
</project>