Update plugin version
[services/jenkins-jobs.git] / jobs / Pre-release / config.xml
1 <?xml version='1.0' encoding='UTF-8'?>
2 <matrix-project plugin="matrix-project@1.11">
3   <actions/>
4   <description>Publish Services or Tools release to archive/. Optionally update symlink. Run only manually.&#xd;
5 This multi-config job runs on backend or download server, determined by args;&#xd;
6 It skips running on another server.&#xd;
7 </description>
8   <keepDependencies>false</keepDependencies>
9   <properties>
10     <hudson.security.AuthorizationMatrixProperty>
11       <permission>hudson.model.Item.Read:anonymous</permission>
12     </hudson.security.AuthorizationMatrixProperty>
13     <hudson.plugins.buildblocker.BuildBlockerProperty plugin="build-blocker-plugin@1.7.3">
14       <useBuildBlocker>false</useBuildBlocker>
15       <blockLevel>UNDEFINED</blockLevel>
16       <scanQueueFor>DISABLED</scanQueueFor>
17       <blockingJobs></blockingJobs>
18     </hudson.plugins.buildblocker.BuildBlockerProperty>
19     <jenkins.model.BuildDiscarderProperty>
20       <strategy class="hudson.tasks.LogRotator">
21         <daysToKeep>-1</daysToKeep>
22         <numToKeep>50</numToKeep>
23         <artifactDaysToKeep>-1</artifactDaysToKeep>
24         <artifactNumToKeep>-1</artifactNumToKeep>
25       </strategy>
26     </jenkins.model.BuildDiscarderProperty>
27     <com.sonyericsson.rebuild.RebuildSettings plugin="rebuild@1.25">
28       <autoRebuild>false</autoRebuild>
29       <rebuildDisabled>false</rebuildDisabled>
30     </com.sonyericsson.rebuild.RebuildSettings>
31     <hudson.model.ParametersDefinitionProperty>
32       <parameterDefinitions>
33         <hudson.model.ChoiceParameterDefinition>
34           <name>project</name>
35           <description></description>
36           <choices class="java.util.Arrays$ArrayList">
37             <a class="string-array">
38               <string>tools</string>
39               <string>services</string>
40             </a>
41           </choices>
42         </hudson.model.ChoiceParameterDefinition>
43       </parameterDefinitions>
44     </hudson.model.ParametersDefinitionProperty>
45   </properties>
46   <scm class="hudson.scm.NullSCM"/>
47   <canRoam>true</canRoam>
48   <disabled>true</disabled>
49   <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
50   <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
51   <triggers/>
52   <concurrentBuild>false</concurrentBuild>
53   <axes>
54     <hudson.matrix.LabelAxis>
55       <name>label</name>
56       <values>
57         <string>backend</string>
58       </values>
59     </hudson.matrix.LabelAxis>
60   </axes>
61   <builders>
62     <hudson.tasks.Shell>
63       <command>#!/bin/sh
64 set -x
65 RSYNC_OPT=&apos;-avz --exclude=micbootstrap --exclude=tizen-downloader --exclude=lthor-tool --exclude=*/repocache --delete-delay&apos;
66
67 modify_repo() {
68   OBS_PATH=$1
69   #echo &quot;modify_repo: OBS_PATH=$OBS_PATH&quot;
70   TEMPARCHIVEDIR=$(mktemp -d)
71   rsync $RSYNC_OPT $OBS_PATH/* $TEMPARCHIVEDIR/
72   # Update the repo file to public URL
73   update_repo_file $TEMPARCHIVEDIR/
74   # Extrace release notes
75   extract_release_notes $TEMPARCHIVEDIR/
76 }
77
78 update_repo_file() {
79   repo_path=$1
80   #echo &quot;update_repo_file: repo_path=$repo_path&quot;
81   old_working_dir=$(pwd)
82   for dir in $(ls $repo_path)
83   do
84       cd $repo_path/$dir
85       # skip if no repo file found
86       [ -f *.repo ] || continue
87
88       # rename the repo file
89       if [ -n &quot;$REPONAME&quot; ]; then
90           # if there&apos;re more than one repo file, only keep the last one
91           for repofile in $(ls *.repo)
92           do
93               mv -f $repofile $REPONAME.repo
94           done
95           sed -i &quot;s#^\[.*\]#\[$REPONAME\]#g&quot; $REPONAME.repo
96           sed -i &quot;s#^name=.*#name=$REPONAME#g&quot; $REPONAME.repo
97           # Disable gpgcheck
98           sed -i &quot;/^gpg/ d&quot; $REPONAME.repo
99           sed -i &apos;/enable/ a gpgcheck=0&apos; $REPONAME.repo
100       fi
101       # update baseurl
102       public_url=$BASEURL/$dir
103       sed -i &quot;s#^baseurl.*#baseurl=$public_url#g&quot; *.repo
104   done
105   cd $old_working_dir
106 }
107
108 extract_release_notes() {
109   repo_dir=$1
110   #echo &quot;extract_release_notes: repo_dir=$repo_dir&quot;
111   dist=($(ls $repo_dir))
112   cwd=$(pwd)
113   rpm_list=$(find $repo_dir -name &apos;*.rpm&apos;)
114   temp_list=$(mktemp)
115
116   for rpm in $rpm_list
117   do
118       release_notes_file=$(rpm -qpl $rpm|grep &quot;/RELEASE_NOTES$&quot;)
119       release_notes_name=$(echo $release_notes_file|sed &apos;s#/usr/share/doc/packages/\([a-z0-9-]*\)/RELEASE_NOTES#RELEASE_NOTES_\U\1#&apos;|| echo &apos;&apos;)
120       [ -n &quot;$release_notes_name&quot; ] || continue
121       grep $release_notes_file $temp_list &amp;&amp; continue
122
123       # keep in temp list
124       echo $release_notes_file &gt;&gt; $temp_list
125
126       tempdir=$(mktemp -d)
127       cwd=$(pwd)
128       cd $tempdir
129       rpm2cpio &lt; $rpm |cpio -idmv
130       cd $cwd
131
132       cp $tempdir/$release_notes_file $repo_dir/$release_notes_name.txt
133       rm -r $tempdir
134   done
135   rm $temp_list
136 }
137
138 ######### start of script ########
139 # OBS project
140 if [ $project = &quot;tools&quot; ]; then
141   obs_project=Tools:
142 elif [ $project = &quot;services&quot; ]; then
143   obs_project=Services:
144 else
145   echo &quot;Error: Unexpected project value: $project&quot;
146   exit 1
147 fi
148
149 SRC_PATH=/srv/obs/repos/$obs_project/Pre-release
150 DEST_PATH=&quot;${IMG_SYNC_DEST_BASE}/$project/pre-release&quot;
151
152 if [ ! -d $SRC_PATH ] ; then
153     echo &quot;Error: Source directory $SRC_PATH does not exist&quot;
154     exit 1
155 fi
156
157 BASEURL=${URL_PUBLIC_REPO_BASE}/$project/pre-release
158 REPONAME=$project
159 TEMPARCHIVEDIR=&quot;&quot;
160
161 modify_repo $SRC_PATH
162 rsync $RSYNC_OPT $TEMPARCHIVEDIR/* $DEST_PATH/
163
164 [ -d $TEMPARCHIVEDIR ] &amp;&amp; rm -rf $TEMPARCHIVEDIR</command>
165     </hudson.tasks.Shell>
166   </builders>
167   <publishers/>
168   <buildWrappers/>
169   <executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
170     <runSequentially>false</runSequentially>
171   </executionStrategy>
172 </matrix-project>