a1a5fde946f20a2698da940cb285b302e06fe21a
[services/jenkins-jobs.git] / jobs / Release / config.xml
1 <?xml version='1.0' encoding='UTF-8'?>
2 <matrix-project plugin="matrix-project@1.10">
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     <com.sonyericsson.rebuild.RebuildSettings plugin="rebuild@1.25">
20       <autoRebuild>false</autoRebuild>
21       <rebuildDisabled>false</rebuildDisabled>
22     </com.sonyericsson.rebuild.RebuildSettings>
23     <jenkins.model.BuildDiscarderProperty>
24       <strategy class="hudson.tasks.LogRotator">
25         <daysToKeep>-1</daysToKeep>
26         <numToKeep>50</numToKeep>
27         <artifactDaysToKeep>-1</artifactDaysToKeep>
28         <artifactNumToKeep>-1</artifactNumToKeep>
29       </strategy>
30     </jenkins.model.BuildDiscarderProperty>
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         <hudson.model.StringParameterDefinition>
44           <name>release_id</name>
45           <description></description>
46           <defaultValue></defaultValue>
47         </hudson.model.StringParameterDefinition>
48         <hudson.model.ChoiceParameterDefinition>
49           <name>destination</name>
50           <description></description>
51           <choices class="java.util.Arrays$ArrayList">
52             <a class="string-array">
53               <string>staging</string>
54               <string>download.tizen.org</string>
55             </a>
56           </choices>
57         </hudson.model.ChoiceParameterDefinition>
58         <hudson.model.ChoiceParameterDefinition>
59           <name>update_latest_release</name>
60           <description></description>
61           <choices class="java.util.Arrays$ArrayList">
62             <a class="string-array">
63               <string>NO</string>
64               <string>YES</string>
65             </a>
66           </choices>
67         </hudson.model.ChoiceParameterDefinition>
68       </parameterDefinitions>
69     </hudson.model.ParametersDefinitionProperty>
70   </properties>
71   <scm class="hudson.scm.NullSCM"/>
72   <canRoam>true</canRoam>
73   <disabled>false</disabled>
74   <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
75   <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
76   <triggers/>
77   <concurrentBuild>false</concurrentBuild>
78   <axes>
79     <hudson.matrix.LabelAxis>
80       <name>label</name>
81       <values>
82         <string>backend</string>
83         <string>download</string>
84       </values>
85     </hudson.matrix.LabelAxis>
86   </axes>
87   <builders>
88     <hudson.tasks.Shell>
89       <command>#!/bin/sh
90 set -x
91 RSYNC_OPT=&apos;-avz --exclude=micbootstrap --exclude=tizen-downloader --exclude=lthor-tool --exclude=*/repocache --delete-delay&apos;
92
93 modify_repo() {
94   OBS_PATH=$1
95   #echo &quot;modify_repo: OBS_PATH=$OBS_PATH&quot;
96   TEMPARCHIVEDIR=$(mktemp -d)
97   rsync $RSYNC_OPT $OBS_PATH/* $TEMPARCHIVEDIR/
98   # Update the repo file to public URL
99   update_repo_file $TEMPARCHIVEDIR/
100   # Extrace release notes
101   extract_release_notes $TEMPARCHIVEDIR/
102 }
103
104 update_repo_file() {
105   repo_path=$1
106   #echo &quot;update_repo_file: repo_path=$repo_path&quot;
107   old_working_dir=$(pwd)
108   for dir in $(ls $repo_path)
109   do
110       cd $repo_path/$dir
111       # skip if no repo file found
112       [ -f *.repo ] || continue
113
114       # rename the repo file
115       if [ -n &quot;$REPONAME&quot; ]; then
116           # if there&apos;re more than one repo file, only keep the last one
117           for repofile in $(ls *.repo)
118           do
119               mv -f $repofile $REPONAME.repo
120           done
121           sed -i &quot;s#^\[.*\]#\[$REPONAME\]#g&quot; $REPONAME.repo
122           sed -i &quot;s#^name=.*#name=$REPONAME#g&quot; $REPONAME.repo
123           # Disable gpgcheck
124           sed -i &quot;/^gpg/ d&quot; $REPONAME.repo
125           sed -i &apos;/enable/ a gpgcheck=0&apos; $REPONAME.repo
126       fi
127       # update baseurl
128       public_url=$BASEURL/$dir
129       sed -i &quot;s#^baseurl.*#baseurl=$public_url#g&quot; *.repo
130   done
131   cd $old_working_dir
132 }
133
134 extract_release_notes() {
135   repo_dir=$1
136   #echo &quot;extract_release_notes: repo_dir=$repo_dir&quot;
137   dist=$(ls $repo_dir)
138   cwd=$(pwd)
139   rpm_list=$(find $repo_dir -name &apos;*.rpm&apos;)
140   temp_list=$(mktemp)
141
142   for rpm in $rpm_list
143   do
144       release_notes_file=$(rpm -qpl $rpm|grep &quot;/RELEASE_NOTES$&quot;)
145       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;)
146       [ -n &quot;$release_notes_name&quot; ] || continue
147       grep $release_notes_file $temp_list &amp;&amp; continue
148
149       # keep in temp list
150       echo $release_notes_file &gt;&gt; $temp_list
151
152       tempdir=$(mktemp -d)
153       cwd=$(pwd)
154       cd $tempdir
155       rpm2cpio &lt; $rpm |cpio -idmv
156       cd $cwd
157
158       cp $tempdir/$release_notes_file $repo_dir/$release_notes_name.txt
159       rm -r $tempdir
160   done
161   rm $temp_list
162 }
163
164 ######### start of script ########
165 if [ -z &quot;$release_id&quot; ] ; then
166     echo &quot;Error: release_id is mandatory.&quot;
167     exit 1
168 fi
169
170 if [ $project = &quot;tools&quot; ]; then
171   obs_project=Tools
172 elif [ $project = &quot;services&quot; ]; then
173   obs_project=Services
174 else
175   echo &quot;Error: Unexpected project value: $project&quot;
176   exit 1
177 fi
178
179 case $destination in
180     &apos;staging&apos;)
181          [ $label != backend ] &amp;&amp; exit 0
182          staging=.staging/
183          SRC_PATH=/srv/obs/repos/$obs_project
184          DEST_PATH=&quot;${IMG_SYNC_DEST_BASE}/${project}/.staging&quot;
185          ;;
186     &apos;download.tizen.org&apos;)
187          [ $label != download ] &amp;&amp; exit 0
188          staging=&quot;&quot;
189          SRC_PATH=/srv/www/download.tizen.org/$project/.staging/archive/$release_id
190          DEST_PATH=/srv/www/download.tizen.org/$project
191          ;;
192     *)
193          echo &quot;Error: Wrong destination&quot;
194          exit 1
195 esac
196
197 if [ ! -d $SRC_PATH ] ; then
198     echo &quot;Error: Source directory $SRC_PATH does not exist&quot;
199     exit 1
200 fi
201
202 BASEURL=${URL_PUBLIC_REPO_BASE}/$project/${staging}archive/$release_id
203 REPONAME=$project
204 TEMPARCHIVEDIR=&quot;&quot;
205
206 modify_repo $SRC_PATH
207 rsync $RSYNC_OPT $TEMPARCHIVEDIR/* $DEST_PATH/archive/$release_id
208
209 if [ &quot;$update_latest_release&quot; = &quot;YES&quot; ]; then
210     [ AAA${TEMPARCHIVEDIR} = &quot;AAA&quot; ] &amp;&amp; modify_repo $SRC_PATH
211     rsync $RSYNC_OPT $TEMPARCHIVEDIR/* $DEST_PATH/latest-release
212 fi
213 [ -d $TEMPARCHIVEDIR ] &amp;&amp; rm -rf $TEMPARCHIVEDIR</command>
214     </hudson.tasks.Shell>
215   </builders>
216   <publishers/>
217   <buildWrappers/>
218   <executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
219     <runSequentially>false</runSequentially>
220   </executionStrategy>
221 </matrix-project>