Add jenkins jobs and jenkins scripts for GBS local full build
authorJunchun Guan <junchunx.guan@intel.com>
Thu, 27 Feb 2014 08:13:35 +0000 (16:13 +0800)
committerJunchun Guan <junchunx.guan@intel.com>
Tue, 4 Mar 2014 09:41:05 +0000 (17:41 +0800)
Two sub-packages introduced:
 - gbs-jenkins-jobs: jenkins job configuation files
 - gbs-jenkins-scripts: scripts used by jenkins jobs

gbs-jenkins-jobs should be installed on jenkins master, and
jenkisn script should be installed on jenkins slave nodes.

Fixes: #1565

Change-Id: I879d238a82739c7cea62a371edf9e8ee7f4fdbb9
Signed-off-by: Junchun Guan <junchunx.guan@intel.com>
Signed-off-by: Zhang Qiang <qiang.z.zhang@intel.com>
12 files changed:
debian/control
debian/gbs-jenkins-jobs.install [new file with mode: 0644]
debian/gbs-jenkins-jobs.postinst [new file with mode: 0644]
debian/gbs-jenkins-scripts.install [new file with mode: 0644]
debian/gbs-jenkins-scripts.postinst [new file with mode: 0644]
debian/rules
jenkins-jobs/configs/GBS-local-build-with-package-list/config.xml [new file with mode: 0644]
jenkins-jobs/configs/GBS-local-full-build/config.xml [new file with mode: 0644]
jenkins-jobs/scripts/common_functions [new file with mode: 0755]
jenkins-jobs/scripts/job_build_packagelist [new file with mode: 0755]
jenkins-jobs/scripts/job_local_full_build [new file with mode: 0755]
packaging/gbs.spec

index e44874d..fcd7ee3 100644 (file)
@@ -58,3 +58,18 @@ Replaces: gbs (<< 0.18.1)
 Description: GBS remotebuild API
  This package contains gbs remotebuild APIs, which can be used by
  external software.
+
+Package: gbs-jenkins-jobs
+Architecture: all
+Depends: ${misc:Depends},
+ jenkins
+Description: GBS local full build jenkins jobs configurations.
+ These jenkins jobs are used to build tizen source from scratch or only a part of packages, and create images finally.
+
+Package: gbs-jenkins-scripts
+Architecture: all
+Depends: ${misc:Depends},
+ gbs,
+ mic
+Description: Jenkins scripts used by gbs-jenkins-job
+ These scripts are used by GBS local full build jenkins jobs. These scripts should be installed on Jenkins slave nodes.
diff --git a/debian/gbs-jenkins-jobs.install b/debian/gbs-jenkins-jobs.install
new file mode 100644 (file)
index 0000000..5b0e00d
--- /dev/null
@@ -0,0 +1 @@
+var/lib/jenkins/jobs/*
diff --git a/debian/gbs-jenkins-jobs.postinst b/debian/gbs-jenkins-jobs.postinst
new file mode 100644 (file)
index 0000000..48999c7
--- /dev/null
@@ -0,0 +1 @@
+chown -R jenkins. /var/lib/jenkins/jobs
diff --git a/debian/gbs-jenkins-scripts.install b/debian/gbs-jenkins-scripts.install
new file mode 100644 (file)
index 0000000..1779501
--- /dev/null
@@ -0,0 +1,3 @@
+var/lib/jenkins/jenkins-scripts/common_functions
+var/lib/jenkins/jenkins-scripts/job_local_full_build
+var/lib/jenkins/jenkins-scripts/job_build_packagelist
diff --git a/debian/gbs-jenkins-scripts.postinst b/debian/gbs-jenkins-scripts.postinst
new file mode 100644 (file)
index 0000000..9e40947
--- /dev/null
@@ -0,0 +1 @@
+chown -R jenkins. /var/lib/jenkins/jenkins-scripts
index fcec0a2..6f59c1c 100644 (file)
@@ -8,6 +8,12 @@ override_dh_auto_install:
        make man
        mkdir -p debian/tmp/usr/share/man/man1
        install -m644 docs/gbs.1 debian/tmp/usr/share/man/man1
+       for job_name in $(shell ls jenkins-jobs/configs); do \
+               mkdir -p debian/tmp/var/lib/jenkins/jobs/$$job_name; \
+               install -m644 jenkins-jobs/configs/$$job_name/config.xml debian/tmp/var/lib/jenkins/jobs/$$job_name; \
+       done
+       mkdir -p debian/tmp/var/lib/jenkins/jenkins-scripts
+       install -m755 jenkins-jobs/scripts/* debian/tmp/var/lib/jenkins/jenkins-scripts
 
 override_dh_auto_test:
        @echo 'Skipping autotests'
diff --git a/jenkins-jobs/configs/GBS-local-build-with-package-list/config.xml b/jenkins-jobs/configs/GBS-local-build-with-package-list/config.xml
new file mode 100644 (file)
index 0000000..df7a4ef
--- /dev/null
@@ -0,0 +1,197 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<project>
+  <actions/>
+  <description>This jenkins job is used to  build  Tizen  sources.&#xd;
+This job is based on &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Repo_%28script%29&quot;&gt;repo&lt;/a&gt; and  &lt;a class=&quot;reference external&quot; href=&quot;https://source.tizen.org/documentation/reference/git-build-system&quot;&gt;GBS&lt;/a&gt;.  Developers can reconfigure&#xd;
+this job to run periodically, of course can be triggered at anytime needed.&lt;/p&gt;&#xd;
+&lt;p&gt;Using this job, developers can specify a list of packages, which just have&#xd;
+been updated in remote repos, and check if the final image can work well&#xd;
+with these changes of packages. To use this job, one remote repo must be&#xd;
+specified, which can be used to get ks file and required by &lt;cite&gt;gbs build&lt;/cite&gt;.&#xd;
+An example of remote repo is shown below:&lt;/p&gt;&#xd;
+&lt;pre class=&quot;literal-block&quot;&gt;&#xd;
+http://download.tizen.org/releases/daily/tizen/ivi/ivi/tizen_20140212.7/&#xd;
+&lt;/pre&gt;&#xd;
+&lt;p&gt;With &lt;strong&gt;PUBLISH&lt;/strong&gt; enabled, build artifacts, including build reports, repos and&#xd;
+images, will be synchronized to respective download servers.&lt;/p&gt;&#xd;
+&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; To get a better understanding of this job, it is highly recommended&#xd;
+that the following document, which provides instructions of the corresponding&#xd;
+manual operations, is read and well understood:&#xd;
+&lt;a class=&quot;reference external&quot; href=&quot;https://source.tizen.org/documentation/developer-guide/creating-tizen-image-scratch&quot;&gt;Creating a Tizen Image from Scratch&lt;/a&gt;&lt;/p&gt;&#xd;
+&lt;p&gt;The following options are supported by this jenkins job:&lt;/p&gt;&#xd;
+&lt;dl class=&quot;docutils&quot;&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;MANIFEST_URL&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;&lt;p class=&quot;first&quot;&gt;The manifest url, which should be recognized by &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Repo_%28script%29&quot;&gt;repo&lt;/a&gt; command,&#xd;
+for example: &lt;cite&gt;review.tizen.org:scm/manifest&lt;/cite&gt;, where &lt;cite&gt;review.tizen.org&lt;/cite&gt;&#xd;
+is the alias name set in ~/.ssh, like:&lt;/p&gt;&#xd;
+&lt;pre class=&quot;literal-block&quot;&gt;&#xd;
+Host review.tizen.org&#xd;
+Hostname review.tizen.org&#xd;
+Port 29418&#xd;
+User &amp;lt;username&amp;gt;&#xd;
+#ProxyCommand connect -S &amp;lt;proxy&amp;gt;:&amp;lt;port&amp;gt; %h %p&#xd;
+&lt;/pre&gt;&#xd;
+&lt;p class=&quot;last&quot;&gt;and, &lt;cite&gt;scm/manifest&lt;/cite&gt; is the manifest path in remote tizen.org gerrit.&lt;/p&gt;&#xd;
+&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;MANIFEST_BRANCHES&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option specifies the manifest branch used for syncing code, this&#xd;
+value will be passed to &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Repo_%28script%29&quot;&gt;repo&lt;/a&gt; command directly.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;PROFILE&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option specifies the target profile, valid values: &lt;cite&gt;IVI&lt;/cite&gt;, &lt;cite&gt;Mobile&lt;/cite&gt;.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;ARCH&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option specifies the arch to be built, valid values: &lt;cite&gt;i586&lt;/cite&gt; and&#xd;
+&lt;cite&gt;armv7l&lt;/cite&gt;.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;REMOTE_REPOS&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;The remote repos for doing local full build using gbs, and get ks file for&#xd;
+image creation.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;KS&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;Specify the ks file name used to create images. The avaliable names&#xd;
+should be in  &lt;strong&gt;REMOTE_REPO&lt;/strong&gt;  specified  above, multiple ks can be&#xd;
+specified seperate by space.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;PACKAGE_LIST&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option specifies the package list, in which the full path of each&#xd;
+package is listed line by line.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;BUILD_RDEPS&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option enables the building with dependency,that is, packages that&#xd;
+depend on packages in &lt;cite&gt;PACKAGE_LIST&lt;/cite&gt; will be built in correct dependency&#xd;
+order.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;PARALEL_THREADS&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option determines how many builder gbs should run in parallel&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;EXCLUDE_PACKAGES&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option specifies the packages that does not participate in building.&#xd;
+And also can be used to break dependency cycles.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;BUILD_ARGS&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;Specify more gbs build options. For more gbs build options and usage&#xd;
+refer to &lt;a class=&quot;reference external&quot; href=&quot;https://source.tizen.org/documentation/reference/git-build-system/usage/gbs-build&quot;&gt;gbs build usage&lt;/a&gt;.  Default value: empty.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;PUBLISH&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option enables the publishing of build artifacts to respective&#xd;
+download servers. Build artifacts include report, images and repos.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;PUBLISH_URL&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;Specify the  URL  address to publish build artifacts. The format of&#xd;
+&lt;cite&gt;PUBLISH_URL&lt;/cite&gt; should be the same as rsync format which can be a local&#xd;
+path or  remote url like: &lt;cite&gt;user&amp;#64;hostname:/path/to/publish_dir&lt;/cite&gt;.&#xd;
+This option only take effect if PUBLISH is enabled.&lt;/dd&gt;&#xd;
+&lt;/dl&gt;</description>
+  <keepDependencies>false</keepDependencies>
+  <properties>
+    <hudson.model.ParametersDefinitionProperty>
+      <parameterDefinitions>
+        <hudson.model.StringParameterDefinition>
+          <name>MANIFEST_URL</name>
+          <description>&lt;p class=&quot;first&quot;&gt;The manifest url, which should be recognized by &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Repo_%28script%29&quot;&gt;repo&lt;/a&gt; command,
+for example: &lt;cite&gt;review.tizen.org:scm/manifest&lt;/cite&gt;, where &lt;cite&gt;review.tizen.org&lt;/cite&gt;
+is the alias name set in ~/.ssh, like:&lt;/p&gt;
+&lt;pre class=&quot;literal-block&quot;&gt;
+Host review.tizen.org
+Hostname review.tizen.org
+Port 29418
+User &amp;lt;username&amp;gt;
+#ProxyCommand connect -S &amp;lt;proxy&amp;gt;:&amp;lt;port&amp;gt; %h %p
+&lt;/pre&gt;
+&lt;p class=&quot;last&quot;&gt;and, &lt;cite&gt;scm/manifest&lt;/cite&gt; is the manifest path in remote tizen.org gerrit.&lt;/p&gt;
+</description>
+          <defaultValue>review.tizen.org:scm/manifest</defaultValue>
+        </hudson.model.StringParameterDefinition>
+        <hudson.model.StringParameterDefinition>
+          <name>MANIFEST_BRANCH</name>
+          <description>This option specifies the manifest branch used for syncing code, this
+value will be passed to &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Repo_%28script%29&quot;&gt;repo&lt;/a&gt; command directly.</description>
+          <defaultValue>tizen</defaultValue>
+        </hudson.model.StringParameterDefinition>
+        <hudson.model.ChoiceParameterDefinition>
+          <name>PROFILE</name>
+          <description>This option specifies the target profile, valid values: &lt;cite&gt;IVI&lt;/cite&gt;, &lt;cite&gt;Mobile&lt;/cite&gt;.</description>
+          <choices class="java.util.Arrays$ArrayList">
+            <a class="string-array">
+              <string>ivi</string>
+              <string>mobile</string>
+            </a>
+          </choices>
+        </hudson.model.ChoiceParameterDefinition>
+        <hudson.model.TextParameterDefinition>
+          <name>REMOTE_REPOS</name>
+          <description>The remote repos for doing local full build using gbs, and get ks file for
+image creation. Example:
+http://download.tizen.org/releases/daily/tizen/ivi/ivi/tizen_20140212.7/</description>
+          <defaultValue>https://download.tizen.org/releases/daily/tizen/ivi/ivi/tizen_20140214.10</defaultValue>
+        </hudson.model.TextParameterDefinition>
+        <hudson.model.StringParameterDefinition>
+          <name>KS</name>
+          <description>ks file name.
+Example:
+  mobile.ks
+
+For multiple ks file use spaces to separate them:
+ mobile.ks mobile-ref.ks</description>
+          <defaultValue>ivi-mbr-i586.ks</defaultValue>
+        </hudson.model.StringParameterDefinition>
+        <hudson.model.BooleanParameterDefinition>
+          <name>BUILD_RDEPS</name>
+          <description>Check this box, all packages depend on specified packages will be built in correct dependency order.</description>
+          <defaultValue>true</defaultValue>
+        </hudson.model.BooleanParameterDefinition>
+        <hudson.model.TextParameterDefinition>
+          <name>PACKAGE_LIST</name>
+          <description>Specify the packages list to be built, and one line for per package. The format should be the detail path in remote gerrit.</description>
+          <defaultValue>apps/core/preloaded/menu-screen
+apps/core/preloaded/settings
+</defaultValue>
+        </hudson.model.TextParameterDefinition>
+        <hudson.model.ChoiceParameterDefinition>
+          <name>ARCH</name>
+          <description>This option specifies the arch to be built, valid values: &lt;cite&gt;i586&lt;/cite&gt;</description>
+          <choices class="java.util.Arrays$ArrayList">
+            <a class="string-array">
+              <string>ia32</string>
+              <string>armv7l</string>
+            </a>
+          </choices>
+        </hudson.model.ChoiceParameterDefinition>
+        <hudson.model.StringParameterDefinition>
+          <name>PARALEL_THREADS</name>
+          <description>This option determines how many builder gbs should run in parallel.</description>
+          <defaultValue>4</defaultValue>
+        </hudson.model.StringParameterDefinition>
+        <hudson.model.StringParameterDefinition>
+          <name>EXCLUDE_PACKAGES</name>
+          <description>This option specifies the packages that does not participate in building.
+And also can be used to break dependency cycles.</description>
+          <defaultValue>texinfo,aul,gettext</defaultValue>
+        </hudson.model.StringParameterDefinition>
+        <hudson.model.StringParameterDefinition>
+          <name>BUILD_ARGS</name>
+          <description>Specify more gbs build options. For more gbs build options and usage
+refer to &lt;a class=&quot;reference external&quot; href=&quot;https://source.tizen.org/documentation/reference/git-build-system/usage/gbs-build&quot;&gt;gbs build usage&lt;/a&gt;.  Default value: empty.</description>
+          <defaultValue></defaultValue>
+        </hudson.model.StringParameterDefinition>
+        <hudson.model.BooleanParameterDefinition>
+          <name>PUBLISH</name>
+          <description>This option enables the publishing of build artifacts to respective download servers. Build artifacts include report, images and repos..</description>
+          <defaultValue>true</defaultValue>
+        </hudson.model.BooleanParameterDefinition>
+        <hudson.model.StringParameterDefinition>
+          <name>PUBLISH_URL</name>
+          <description>Specify the  URL  address to publish build artifacts. The format of
+&lt;cite&gt;PUBLISH_URL&lt;/cite&gt; should be the same as rsync format which can be a local
+path or  remote url like: &lt;cite&gt;user&amp;#64;hostname:/path/to/publish_dir&lt;/cite&gt;.
+This option only take effect if PUBLISH is enabled.</description>
+          <defaultValue></defaultValue>
+        </hudson.model.StringParameterDefinition>
+      </parameterDefinitions>
+    </hudson.model.ParametersDefinitionProperty>
+  </properties>
+  <scm class="hudson.scm.NullSCM"/>
+  <canRoam>true</canRoam>
+  <disabled>false</disabled>
+  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
+  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
+  <triggers/>
+  <concurrentBuild>false</concurrentBuild>
+  <builders>
+    <hudson.tasks.Shell>
+      <command>${JENKINS_HOME}/jenkins-scripts/job_build_packagelist</command>
+    </hudson.tasks.Shell>
+  </builders>
+  <publishers/>
+  <buildWrappers/>
+</project>
diff --git a/jenkins-jobs/configs/GBS-local-full-build/config.xml b/jenkins-jobs/configs/GBS-local-full-build/config.xml
new file mode 100644 (file)
index 0000000..e2d63f1
--- /dev/null
@@ -0,0 +1,156 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<project>
+  <actions/>
+  <description>This jenkins job is used to  build  Tizen  sources.&#xd;
+This job is based on &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Repo_%28script%29&quot;&gt;repo&lt;/a&gt; and  &lt;a class=&quot;reference external&quot; href=&quot;https://source.tizen.org/documentation/reference/git-build-system&quot;&gt;GBS&lt;/a&gt;.  Developers can reconfigure&#xd;
+this job to run periodically, of course can be triggered at anytime needed.&lt;/p&gt;&#xd;
+&lt;p&gt;With &lt;strong&gt;PUBLISH&lt;/strong&gt; enabled, build artifacts, including build reports, repos and&#xd;
+images, will be synchronized to respective download servers.&lt;/p&gt;&#xd;
+&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; To get a better understanding of this job, it is highly recommended&#xd;
+that the following document, which provides instructions of the corresponding&#xd;
+manual operations, is read and well understood:&#xd;
+&lt;a class=&quot;reference external&quot; href=&quot;https://source.tizen.org/documentation/developer-guide/creating-tizen-image-scratch&quot;&gt;Creating a Tizen Image from Scratch&lt;/a&gt;&lt;/p&gt;&#xd;
+&lt;p&gt;The following options are supported by this jenkins job:&lt;/p&gt;&#xd;
+&lt;dl class=&quot;docutils&quot;&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;MANIFEST_URL&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;&lt;p class=&quot;first&quot;&gt;The manifest url, which should be recognized by &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Repo_%28script%29&quot;&gt;repo&lt;/a&gt; command,&#xd;
+for example: &lt;cite&gt;review.tizen.org:scm/manifest&lt;/cite&gt;, where &lt;cite&gt;review.tizen.org&lt;/cite&gt;&#xd;
+is the alias name set in ~/.ssh, like:&lt;/p&gt;&#xd;
+&lt;pre class=&quot;literal-block&quot;&gt;&#xd;
+Host review.tizen.org&#xd;
+Hostname review.tizen.org&#xd;
+Port 29418&#xd;
+User &amp;lt;username&amp;gt;&#xd;
+#ProxyCommand connect -S &amp;lt;proxy&amp;gt;:&amp;lt;port&amp;gt; %h %p&#xd;
+&lt;/pre&gt;&#xd;
+&lt;p class=&quot;last&quot;&gt;and, &lt;cite&gt;scm/manifest&lt;/cite&gt; is the manifest path in remote tizen.org gerrit.&lt;/p&gt;&#xd;
+&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;MANIFEST_BRANCHES&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option specifies the manifest branch used for syncing code, this&#xd;
+value will be passed to &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Repo_%28script%29&quot;&gt;repo&lt;/a&gt; command directly.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;PROFILE&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option specifies the target profile, valid values: &lt;cite&gt;IVI&lt;/cite&gt;, &lt;cite&gt;Mobile&lt;/cite&gt;.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;ARCH&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option specifies the arch to be built, valid values: &lt;cite&gt;i586&lt;/cite&gt; and&#xd;
+&lt;cite&gt;armv7l&lt;/cite&gt;.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;REMOTE_REPOS&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;The remote repos for doing local full build using gbs, and get ks file for&#xd;
+image creation.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;PARALEL_THREADS&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option determines how many builder gbs should run in parallel&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;EXCLUDE_PACKAGES&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option specifies the packages that does not participate in building.&#xd;
+And also can be used to break dependency cycles.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;BUILD_ARGS&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;Specify more gbs build options. For more gbs build options and usage&#xd;
+refer to &lt;a class=&quot;reference external&quot; href=&quot;https://source.tizen.org/documentation/reference/git-build-system/usage/gbs-build&quot;&gt;gbs build usage&lt;/a&gt;.  Default value: empty.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;PUBLISH&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;This option enables the publishing of build artifacts to respective&#xd;
+download servers. Build artifacts include report, images and repos.&lt;/dd&gt;&#xd;
+&lt;dt&gt;&lt;tt class=&quot;docutils literal&quot;&gt;PUBLISH_URL&lt;/tt&gt;&lt;/dt&gt;&#xd;
+&lt;dd&gt;Specify the  URL  address to publish build artifacts. The format of&#xd;
+&lt;cite&gt;PUBLISH_URL&lt;/cite&gt; should be the same as rsync format which can be a local&#xd;
+path or  remote url like: &lt;cite&gt;user&amp;#64;hostname:/path/to/publish_dir&lt;/cite&gt;.&#xd;
+This option only take effect if PUBLISH is enabled.&lt;/dd&gt;&#xd;
+&lt;/dl&gt;</description>
+  <keepDependencies>false</keepDependencies>
+  <properties>
+    <hudson.model.ParametersDefinitionProperty>
+      <parameterDefinitions>
+        <hudson.model.StringParameterDefinition>
+          <name>MANIFEST_URL</name>
+          <description>&lt;p class=&quot;first&quot;&gt;The manifest url, which should be recognized by &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Repo_%28script%29&quot;&gt;repo&lt;/a&gt; command,
+for example: &lt;cite&gt;review.tizen.org:scm/manifest&lt;/cite&gt;, where &lt;cite&gt;review.tizen.org&lt;/cite&gt;
+is the alias name set in ~/.ssh, like:&lt;/p&gt;
+&lt;pre class=&quot;literal-block&quot;&gt;
+Host review.tizen.org
+Hostname review.tizen.org
+Port 29418
+User &amp;lt;username&amp;gt;
+#ProxyCommand connect -S &amp;lt;proxy&amp;gt;:&amp;lt;port&amp;gt; %h %p
+&lt;/pre&gt;
+&lt;p class=&quot;last&quot;&gt;and, &lt;cite&gt;scm/manifest&lt;/cite&gt; is the manifest path in remote tizen.org gerrit.&lt;/p&gt;
+</description>
+          <defaultValue>review.tizen.org:scm/manifest</defaultValue>
+        </hudson.model.StringParameterDefinition>
+        <hudson.model.StringParameterDefinition>
+          <name>MANIFEST_BRANCH</name>
+          <description>This option specifies the manifest branch used for syncing code, this
+value will be passed to &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Repo_%28script%29&quot;&gt;repo&lt;/a&gt; command directly.</description>
+          <defaultValue>tizen</defaultValue>
+        </hudson.model.StringParameterDefinition>
+        <hudson.model.ChoiceParameterDefinition>
+          <name>PROFILE</name>
+          <description>This option specifies the target profile, valid values: &lt;cite&gt;IVI&lt;/cite&gt;, &lt;cite&gt;Mobile&lt;/cite&gt;.</description>
+          <choices class="java.util.Arrays$ArrayList">
+            <a class="string-array">
+              <string>ivi</string>
+              <string>mobile</string>
+            </a>
+          </choices>
+        </hudson.model.ChoiceParameterDefinition>
+        <hudson.model.TextParameterDefinition>
+          <name>REMOTE_REPOS</name>
+          <description>The remote repos for doing local full build using gbs, and get ks file for
+image creation. Example:
+http://download.tizen.org/releases/daily/tizen/ivi/ivi/tizen_20140212.7/</description>
+          <defaultValue>https://download.tizen.org/releases/daily/tizen/ivi/ivi/tizen_20140214.10</defaultValue>
+        </hudson.model.TextParameterDefinition>
+        <hudson.model.ChoiceParameterDefinition>
+          <name>ARCH</name>
+          <description>This option specifies the arch to be built, valid values: &lt;cite&gt;i586&lt;/cite&gt;</description>
+          <choices class="java.util.Arrays$ArrayList">
+            <a class="string-array">
+              <string>i586</string>
+              <string>armv7l</string>
+            </a>
+          </choices>
+        </hudson.model.ChoiceParameterDefinition>
+        <hudson.model.StringParameterDefinition>
+          <name>PARALEL_THREADS</name>
+          <description>This option determines how many builder gbs should run in parallel.</description>
+          <defaultValue>4</defaultValue>
+        </hudson.model.StringParameterDefinition>
+        <hudson.model.StringParameterDefinition>
+          <name>EXCLUDE_PACKAGES</name>
+          <description>This option specifies the packages that does not participate in building.
+And also can be used to break dependency cycles.</description>
+          <defaultValue>texinfo,aul,gettext</defaultValue>
+        </hudson.model.StringParameterDefinition>
+        <hudson.model.StringParameterDefinition>
+          <name>BUILD_ARGS</name>
+          <description>Specify more gbs build options. For more gbs build options and usage
+refer to &lt;a class=&quot;reference external&quot; href=&quot;https://source.tizen.org/documentation/reference/git-build-system/usage/gbs-build&quot;&gt;gbs build usage&lt;/a&gt;.  Default value: empty.</description>
+          <defaultValue>platform/upstream/image-configurations</defaultValue>
+        </hudson.model.StringParameterDefinition>
+        <hudson.model.BooleanParameterDefinition>
+          <name>PUBLISH</name>
+          <description>This option enables the publishing of build artifacts to respective download servers. Build artifacts include report, images and repos..</description>
+          <defaultValue>true</defaultValue>
+        </hudson.model.BooleanParameterDefinition>
+        <hudson.model.StringParameterDefinition>
+          <name>PUBLISH_URL</name>
+          <description>Specify the  URL  address to publish build artifacts. The format of
+&lt;cite&gt;PUBLISH_URL&lt;/cite&gt; should be the same as rsync format which can be a local
+path or  remote url like: &lt;cite&gt;user&amp;#64;hostname:/path/to/publish_dir&lt;/cite&gt;.
+This option only take effect if PUBLISH is enabled.</description>
+          <defaultValue></defaultValue>
+        </hudson.model.StringParameterDefinition>
+      </parameterDefinitions>
+    </hudson.model.ParametersDefinitionProperty>
+  </properties>
+  <scm class="hudson.scm.NullSCM"/>
+  <canRoam>true</canRoam>
+  <disabled>false</disabled>
+  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
+  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
+  <triggers/>
+  <concurrentBuild>false</concurrentBuild>
+  <builders>
+    <hudson.tasks.Shell>
+      <command>${JENKINS_HOME}/jenkins-scripts/job_local_full_build</command>
+    </hudson.tasks.Shell>
+  </builders>
+  <publishers/>
+  <buildWrappers/>
+</project>
diff --git a/jenkins-jobs/scripts/common_functions b/jenkins-jobs/scripts/common_functions
new file mode 100755 (executable)
index 0000000..a68a721
--- /dev/null
@@ -0,0 +1,110 @@
+#!/bin/bash -xe
+#
+# Copyright (c) 2014 Intel, Inc.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc., 59
+# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+# COMMON ENVIRONMENT VARIABLES
+# $WORKSPACE is the jenkins workspace, the default is /var/lib/jenkins/workspace/%{jenkins_job_name}
+TMP_DIR="$WORKSPACE/.tmp"
+TIZEN_SOURCE="$WORKSPACE/tizen"
+GBS_BUILD_ROOT="$WORKSPACE/GBS-ROOT"
+BUILD_ID=
+LOCAL_REPO_DIR=
+KS_FILES=
+OUTPUT_DIR="$WORKSPACE/$JOB_NAME/tizen_$(date +%Y%m%d)#${BUILD_NUMBER}"
+GBS_BUILD_ARGS="--clean-once" # default enabled args
+
+# Prepare build env
+function prepare_build_env()
+{
+    test -e $TIZEN_SOURCE || mkdir -p $TIZEN_SOURCE
+    sudo rm -rf "$JOB_NAME"
+    mkdir -p $OUTPUT_DIR/repos
+    mkdir -p $OUTPUT_DIR/builddata
+    mkdir -p $OUTPUT_DIR/images
+    mkdir -p $OUTPUT_DIR/builddata/image-configs
+    BUILD_ID=$(basename $(echo $REMOTE_REPOS|awk '{print $1}'))
+
+    test -e $TMP_DIR || mkdir $TMP_DIR
+}
+
+function cleanup_and_exit ()
+{
+    sudo rm $OUTPUT_DIR -rf
+    rm -rf $TMP_DIR
+    exit $1
+}
+
+# Build gbs args using jenkins job options
+function gen_gbs_build_args()
+{
+    GBS_BUILD_ARGS="-B $GBS_BUILD_ROOT $GBS_BUILD_ARGS $BUILD_ARGS "
+    [ -n "$EXCLUDE_PACKAGES" ] && GBS_BUILD_ARGS="$GBS_BUILD_ARGS --exclude=$EXCLUDE_PACKAGES"
+    [ -z "$PARALEL_THREADS" ] && $PARALEL_THREADS="4"
+    GBS_BUILD_ARGS="$GBS_BUILD_ARGS --threads=$PARALEL_THREADS"
+    for repo in $REMOTE_REPOS
+    do
+        GBS_BUILD_ARGS="$GBS_BUILD_ARGS -R $repo"
+    done
+}
+
+# Update ks files with new repos
+function update_ks_file(){
+    # KS files
+    sed -i 's#^\(repo.*\)http.*@BUILD_ID@\(.*\)$#\1'"${REMOTE_REPOS}"'\2#' $KS_FILES
+    sed -i 's/^repo .*/& --priority=99 --ssl_verify=no/' $KS_FILES
+    sed -i "/^repo/ a\repo --name=local  --baseurl=file://$LOCAL_REPO_DIR --priority=1" $KS_FILES
+}
+
+
+#Create images
+function create_images()
+{
+    update_ks_file
+
+    for ks in $KS_FILES
+    do
+        ks_file=$(basename $ks)
+        sudo mic cr auto $ks --release=$BUILD_ID \
+                             --logfile=${BUILD_ID}_${ks_file%.*} \
+                             -o $OUTPUT_DIR/images || true
+    done
+
+    if [ -e "$OUTPUT_DIR/images/${BUILD_ID}/images" ]; then
+        sudo mv $OUTPUT_DIR/images/${BUILD_ID}/images/* $OUTPUT_DIR/images/
+        sudo rm $OUTPUT_DIR/images/${BUILD_ID} -rf
+    fi
+}
+
+# publish build artifacts
+function publish_artifacts()
+{
+    cd $OUTPUT_DIR
+    if [ -e "$LOCAL_REPO_DIR/repodata" -a \
+         -e "$LOCAL_REPO_DIR/RPMS" -a \
+         -e "$LOCAL_REPO_DIR/logs" -a \
+         -e "$LOCAL_REPO_DIR/index.html" ]; then
+        ln -s "$LOCAL_REPO_DIR/repodata" "$LOCAL_REPO_DIR/RPMS" repos/
+        cp $LOCAL_REPO_DIR/index.html builddata/
+        ln -s $LOCAL_REPO_DIR/logs builddata/
+        rsync -avzk "$WORKSPACE/$JOB_NAME" $PUBLISH_URL || cleanup_and_exit 1
+    else
+        echo "No build report generated"
+    fi
+}
+
+
+
diff --git a/jenkins-jobs/scripts/job_build_packagelist b/jenkins-jobs/scripts/job_build_packagelist
new file mode 100755 (executable)
index 0000000..e822436
--- /dev/null
@@ -0,0 +1,110 @@
+#!/bin/bash -xe
+#
+# Copyright (c) 2014 Intel, Inc.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc., 59
+# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+jenkins_script_dir=$(dirname $0)
+source $jenkins_script_dir/common_functions
+
+function update_manifest()
+{
+    # Manifest in-consistant issues
+    echo fix error in $MANIFEST_FILE
+    sed -i 's|system\(/smart\)|connectivity\1|g' $TMP_DIR/$MANIFEST_FILE
+    sed -i '/<remote fetch=/,+1 d' $TMP_DIR/$MANIFEST_FILE
+}
+
+# Clone & sync source code
+function prepare_tizen_src()
+{
+    pushd $TIZEN_SOURCE
+    rm .repo/manifests -rf
+    rm .repo/local_manifests -rf
+    repo init -u $MANIFEST_URL -b $MANIFEST_BRANCH -m ${PROFILE}.xml
+    popd
+
+    #Update original manifest by removing duplicated packags
+    #with specified package list to be built
+    HEADER="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+    <manifest>
+    "
+    for pkg in $PACKAGE_LIST
+    do
+        sed -i "\,\"$pkg\",d" $TMP_DIR/$MANIFEST_FILE
+        HEADER="$HEADER <project name=\"$pkg\" path=\"$pkg\" />
+"
+    done
+
+    HEADER="$HEADER</manifest>"
+
+    if [ ! -d $LOCAL_MANIFEST_DIR ]; then
+        mkdir $LOCAL_MANIFEST_DIR
+    fi
+
+    echo "create user customized local manifest: ${LOCAL_MANIFEST_DIR}/local.xml"
+
+    cat >"${LOCAL_MANIFEST_DIR}/local.xml" <<EOF
+$HEADER
+EOF
+
+    echo replace .repo/manifests/mobile/projects.xml with $MANIFEST_FILE
+    cp $TMP_DIR/$MANIFEST_FILE "${TIZEN_SOURCE}/.repo/manifests/$PROFILE/projects.xml"
+
+    pushd $TIZEN_SOURCE
+    #repo sync
+    popd
+}
+
+#MAIN START
+
+prepare_build_env
+
+MANIFEST_FILE="${BUILD_ID}_${ARCH}.xml"
+MANIFEST_FILE_URL="$REMOTE_REPOS/builddata/manifest/${MANIFEST_FILE}"
+LOCAL_MANIFEST_DIR="$TIZEN_SOURCE/.repo/local_manifests"
+[ $ARCH = ia32 ] && ARCH=i586
+
+#Download ks files
+for ks in $KS
+do
+    wget -q "$REMOTE_REPOS/builddata/image-configs/$ks" -O $TMP_DIR/$ks
+    KS_FILES="$KS_FILES $TMP_DIR/$ks"
+done
+
+#Download manifest file released in specified $REMOTE_REPOS
+wget -q $MANIFEST_FILE_URL -O "$TMP_DIR/$MANIFEST_FILE"
+update_manifest
+# prepare manifest and sync tizen src
+prepare_tizen_src
+
+profile_name=$(sed -n 's/profile.*=.*profile\.\(.*\)/\1/p' $TIZEN_SOURCE/.gbs.conf)
+LOCAL_REPO_DIR="$GBS_BUILD_ROOT/local/repos/$profile_name/$ARCH"
+
+#Building tizen source packages using gbs build
+cd $TIZEN_SOURCE
+gen_gbs_build_args
+[ "x$BUILD_RDEPS" == "xtrue" ] && GBS_BUILD_ARGS="$GBS_BUILD_ARGS --rdeps"
+PKG_LIST=$(echo $PACKAGE_LIST|sed 's/ /,/g')
+gbs build --arch $ARCH $GBS_BUILD_ARGS --package-list=$PKG_LIST  || true
+
+# Building Images
+create_images
+
+#Publish repos, images and build reports
+if [ $PUBLISH = true -a -n "$PUBLISH_URL" ]; then
+    publish_artifacts
+fi
+
+cleanup_and_exit 0
diff --git a/jenkins-jobs/scripts/job_local_full_build b/jenkins-jobs/scripts/job_local_full_build
new file mode 100755 (executable)
index 0000000..3b8083f
--- /dev/null
@@ -0,0 +1,74 @@
+#!/bin/bash -xe
+#
+# Copyright (c) 2014 Intel, Inc.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc., 59
+# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+jenkins_script_dir=$(dirname $0)
+source $jenkins_script_dir/common_functions
+
+# Clone & sync source code
+function prepare_tizen_src()
+{
+    pushd $TIZEN_SOURCE
+    repo init -u $MANIFEST_URL -b $MANIFEST_BRANCH -m ${PROFILE}.xml
+    repo sync
+    popd
+}
+
+# Get ks files via unpack image-configurations.rpm
+function get_ks_files
+{
+    image_configurations_rpm=`find $LOCAL_REPO_DIR -name "image-configurations*.noarch.rpm"`
+    if [ -z $image_configurations_rpm ]; then
+        echo "No image-configuation rpm generated, so can't get ks files"
+        return 1
+    fi
+
+    rpm -K $image_configurations_rpm || cleanup_and_exit 1;
+
+    for ks_file in $(rpm2cpio $image_configurations_rpm |cpio -t)
+    do
+        echo $ks_file|grep "ks$" || continue
+        ks_base_name=$(basename $ks_file)
+        rpm2cpio $image_configurations_rpm |cpio -i --quiet --to-stdout $ks_file >"$OUTPUT_DIR/builddata/image-configs/$ks_base_name"
+        KS_FILES="$KS_FILES $OUTPUT_DIR/builddata/image-configs/$ks_base_name"
+    done
+
+}
+
+
+#MAIN START
+
+prepare_build_env
+
+prepare_tizen_src
+
+profile_name=$(sed -n 's/profile.*=.*profile\.\(.*\)/\1/p' $TIZEN_SOURCE/.gbs.conf)
+LOCAL_REPO_DIR="$GBS_BUILD_ROOT/local/repos/$profile_name/$ARCH"
+
+#Building tizen source packages using gbs build
+cd $TIZEN_SOURCE
+gen_gbs_build_args
+gbs build --arch $ARCH $GBS_BUILD_ARGS || true
+
+# Building Images
+get_ks_files && create_images
+
+#Publish repos, images and build reports
+if [ $PUBLISH = true -a -n "$PUBLISH_URL" ]; then
+    publish_artifacts
+fi
+
+cleanup_and_exit 0
index 45c2c7c..61b73b5 100644 (file)
@@ -1,5 +1,8 @@
 %{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
 %{!?python_version: %define python_version %(%{__python} -c "import sys; sys.stdout.write(sys.version[:3])")}
+%define jobs_dir /var/lib/jenkins/jobs
+%define scripts_dir /var/lib/jenkins/jenkins-scripts
+
 Name:       gbs
 Summary:    The command line tools for Tizen package developers
 Version:    0.20
@@ -74,6 +77,21 @@ Requires:      git-buildpackage-rpm
 This package contains gbs remotebuild APIs, which can be used by
 external software.
 
+%package jenkins-jobs
+Summary: GBS local full build jenkins jobs configurations.
+
+%description jenkins-jobs
+These jenkins jobs are used to build tizen source from scratch or
+only a part of packages, and create images finally.
+
+%package jenkins-scripts
+Summary:  Jenkins scripts used by gbs-jenkins-job
+Requires: gbs
+Requires: mic
+
+%description jenkins-scripts
+These scripts are used by GBS local full build jenkins jobs. These
+scripts should be installed on Jenkins slave nodes.
 
 %prep
 %setup -q -n %{name}-%{version}
@@ -89,6 +107,17 @@ make man
 mkdir -p %{buildroot}/%{_prefix}/share/man/man1
 install -m644 docs/gbs.1 %{buildroot}/%{_prefix}/share/man/man1
 
+# Install Jenkins Jobs
+for job_name in $(ls jenkins-jobs/configs)
+do
+    mkdir -p %{buildroot}/%{jobs_dir}/${job_name}
+    install -m644 jenkins-jobs/configs/${job_name}/config.xml %{buildroot}/%{jobs_dir}/${job_name}
+done
+
+#Install Jenkins Scripts
+mkdir -p %{buildroot}/%{scripts_dir}
+install -m755 jenkins-jobs/scripts/*  %{buildroot}/%{scripts_dir}
+
 %clean
 rm -rf %{buildroot}
 
@@ -128,3 +157,20 @@ rm -rf %{buildroot}
 %files remotebuild
 %defattr(-,root,root,-)
 %{python_sitelib}/gitbuildsys/cmd_remotebuild.py*
+
+%files jenkins-jobs
+%defattr(-,jenkins,jenkins,-)
+%dir /var/lib/jenkins
+%dir %{jobs_dir}
+%dir %{jobs_dir}/GBS-local-full-build
+%dir %{jobs_dir}/GBS-local-build-with-package-list
+%{jobs_dir}/GBS-local-full-build/config.xml
+%{jobs_dir}/GBS-local-build-with-package-list/config.xml
+
+%files jenkins-scripts
+%defattr(-,jenkins,jenkins,-)
+%dir /var/lib/jenkins
+%dir %{scripts_dir}
+%{scripts_dir}/job_local_full_build
+%{scripts_dir}/job_build_packagelist
+%{scripts_dir}/common_functions