Create jenkins user in preinstall step
authorJunchun Guan <junchunx.guan@intel.com>
Fri, 14 Nov 2014 03:22:35 +0000 (11:22 +0800)
committerJunchun Guan <junchunx.guan@intel.com>
Thu, 29 Jan 2015 13:57:30 +0000 (21:57 +0800)
Change-Id: Ief1d33a7c773eb6fb4367cd49542d03bfd72d385
Signed-off-by: Junchun Guan <junchunx.guan@intel.com>
debian/control
debian/gbs-jenkins-jobs.preinst [new file with mode: 0644]
debian/gbs-jenkins-scripts.preinst [new file with mode: 0644]
packaging/.extra-repos [deleted file]
packaging/gbs.spec

index 9bff4e4..8839b25 100644 (file)
@@ -62,7 +62,6 @@ Description: GBS remotebuild API
 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.
 
@@ -71,6 +70,5 @@ Architecture: all
 Depends: ${misc:Depends},
  gbs,
  mic,
- jenkins
 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.preinst b/debian/gbs-jenkins-jobs.preinst
new file mode 100644 (file)
index 0000000..e4928b1
--- /dev/null
@@ -0,0 +1,15 @@
+: ${JENKINS_USER:=jenkins}
+: ${JENKINS_GROUP:=jenkins}
+
+# Create jenkins group and user if they don't exist.
+# sometimes tools that users want Jenkins to run need a shell,
+# so use /bin/bash. See JENKINS-4830
+if ! getent group "$JENKINS_GROUP" > /dev/null; then
+    addgroup --system --quiet "$JENKINS_GROUP"
+fi
+if ! id "$JENKINS_USER" >/dev/null 2>&1 ; then
+    adduser --system --quiet --home /var/lib/jenkins --no-create-home \
+        --ingroup "$JENKINS_GROUP" --disabled-password --shell /bin/bash \
+        --gecos 'Jenkins' \
+        "$JENKINS_USER"
+fi
diff --git a/debian/gbs-jenkins-scripts.preinst b/debian/gbs-jenkins-scripts.preinst
new file mode 100644 (file)
index 0000000..e4928b1
--- /dev/null
@@ -0,0 +1,15 @@
+: ${JENKINS_USER:=jenkins}
+: ${JENKINS_GROUP:=jenkins}
+
+# Create jenkins group and user if they don't exist.
+# sometimes tools that users want Jenkins to run need a shell,
+# so use /bin/bash. See JENKINS-4830
+if ! getent group "$JENKINS_GROUP" > /dev/null; then
+    addgroup --system --quiet "$JENKINS_GROUP"
+fi
+if ! id "$JENKINS_USER" >/dev/null 2>&1 ; then
+    adduser --system --quiet --home /var/lib/jenkins --no-create-home \
+        --ingroup "$JENKINS_GROUP" --disabled-password --shell /bin/bash \
+        --gecos 'Jenkins' \
+        "$JENKINS_USER"
+fi
diff --git a/packaging/.extra-repos b/packaging/.extra-repos
deleted file mode 100644 (file)
index 8179835..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-openSUSE-12.3:http://linux-ftp.fi.intel.com/repo/jenkins/opensuse-stable
-openSUSE-13.1:http://linux-ftp.fi.intel.com/repo/jenkins/opensuse-stable
-Fedora-19:http://linux-ftp.fi.intel.com/repo/jenkins/redhat-stable
-Fedora-20:http://linux-ftp.fi.intel.com/repo/jenkins/redhat-stable
-CentOS-6.6:http://linux-ftp.fi.intel.com/repo/jenkins/redhat-stable
-CentOS-7:http://linux-ftp.fi.intel.com/repo/jenkins/redhat-stable
-Debian-7.8:deb http://linux-ftp.fi.intel.com/repo/jenkins/debian-stable /
-Ubuntu-12.04:deb http://linux-ftp.fi.intel.com/repo/jenkins/debian-stable /
-Ubuntu-14.04:deb http://linux-ftp.fi.intel.com/repo/jenkins/debian-stable /
-Ubuntu-14.10:deb http://linux-ftp.fi.intel.com/repo/jenkins/debian-stable /
index f5f359f..14597d6 100644 (file)
@@ -79,7 +79,7 @@ external software.
 
 %package jenkins-jobs
 Summary: GBS local full build jenkins jobs configurations.
-Requires: jenkins
+PreReq:  /usr/sbin/groupadd /usr/sbin/useradd
 
 %description jenkins-jobs
 These jenkins jobs are used to build tizen source from scratch or
@@ -87,9 +87,9 @@ only a part of packages, and create images finally.
 
 %package jenkins-scripts
 Summary:  Jenkins scripts used by gbs-jenkins-job
+PreReq:   /usr/sbin/groupadd /usr/sbin/useradd
 Requires: gbs
 Requires: mic
-Requires: jenkins
 
 %description jenkins-scripts
 These scripts are used by GBS local full build jenkins jobs. These
@@ -103,6 +103,11 @@ scripts should be installed on Jenkins slave nodes.
 %{__python} setup.py build
 make man
 
+%pre
+/usr/bin/getent group jenkins >/dev/null || /usr/sbin/groupadd -r jenkins &>/dev/null || :
+/usr/bin/getent passwd jenkins >/dev/null || /usr/sbin/useradd -g jenkins -s /bin/bash -r -c "Jenkins Continuous Build server" \
+    -d "%{workdir}" jenkins &>/dev/null || :
+
 %install
 %{__python} setup.py install --prefix=%{_prefix} --root=%{buildroot}