Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 2b80feec01bee1843c5102c36918210f4dfedf19 @dann committed Dec 24, 2011
Showing with 309 additions and 0 deletions.
  1. +39 −0 README.md
  2. +162 −0 config.xml
  3. +43 −0 setup_jenkins_job_template.sh
  4. +65 −0 setup_jenkins_modules.sh
@@ -0,0 +1,39 @@
+# NAME
+Template for Jenkins Jobs for Perl Projects
+
+# HOW TO INSTALL
+## Install Jenkins plugins
+
+Install jenkins plugins and perl modules for the jenkins project
+using setup_jenkins_modules.sh.
+See configuration section in the script before you run the script.
+
+ ./setup_jenkins_modules.sh
+
+## Install template for jenkins jobs
+
+Install the template for jenkins jobs for perl projects using
+setup_jenkins_project_template.sh.
+See configuration section in the script before you run the script.
+
+ ./setup_jenkins_project_template.sh
+
+# SOURCE AVAILABILITY
+
+This source is in Github:
+
+ http://github.com/dann/perl-jenkins-template
+
+# CONTRIBUTORS
+
+Many thanks to:
+
+
+# AUTHOR
+
+Dann <techmemo at gmail dot com>
+
+# LICENSE
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
@@ -0,0 +1,162 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<project>
+ <actions/>
+ <description></description>
+ <keepDependencies>false</keepDependencies>
+ <properties/>
+ <scm class="hudson.plugins.git.GitSCM">
+ <configVersion>2</configVersion>
+ <userRemoteConfigs>
+ <hudson.plugins.git.UserRemoteConfig>
+ <name></name>
+ <refspec></refspec>
+ <url>https://github.com/dann/p5-test-loadallmodules.git</url>
+ </hudson.plugins.git.UserRemoteConfig>
+ </userRemoteConfigs>
+ <branches>
+ <hudson.plugins.git.BranchSpec>
+ <name>**</name>
+ </hudson.plugins.git.BranchSpec>
+ </branches>
+ <disableSubmodules>false</disableSubmodules>
+ <recursiveSubmodules>false</recursiveSubmodules>
+ <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
+ <authorOrCommitter>false</authorOrCommitter>
+ <clean>false</clean>
+ <wipeOutWorkspace>false</wipeOutWorkspace>
+ <pruneBranches>false</pruneBranches>
+ <remotePoll>false</remotePoll>
+ <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
+ <gitTool>Default</gitTool>
+ <submoduleCfg class="list"/>
+ <relativeTargetDir></relativeTargetDir>
+ <reference></reference>
+ <excludedRegions></excludedRegions>
+ <excludedUsers></excludedUsers>
+ <gitConfigName></gitConfigName>
+ <gitConfigEmail></gitConfigEmail>
+ <skipTag>false</skipTag>
+ <scmName></scmName>
+ </scm>
+ <canRoam>true</canRoam>
+ <disabled>false</disabled>
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
+ <triggers class="vector"/>
+ <concurrentBuild>false</concurrentBuild>
+ <builders>
+ <hudson.tasks.Shell>
+ <command>set -ex
+
+#===============================================
+# Configuration
+#===============================================
+export PATH=&quot;/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:${PATH}&quot;
+export LOG_DIR=$WORKSPACE/logs
+export PERL5LIB=&quot;$WORKSPACE/lib:$WORKSPACE/t/lib:$WORKSPACE/t/*/lib:${PERL5LIB}&quot;
+export PERL_TEST_HARNET_DUMP_TAP=$LOG_DIR
+export TEST_VERBOSE=1
+
+#===============================================
+# Main
+#===============================================
+clean() {
+ [ -f Makefile ] &amp;&amp; make -k realclean
+ rm -rf Makefile Makfile.old MANIFEST blib *.tar.gz
+ rm -rf $LOG_DIR
+ cover -delete
+}
+
+setup() {
+ perl Makefile.PL
+ mkdir -p $LOG_DIR
+}
+do_test() {
+ HARNESS_PERL_SWITCHES=-MDevel::Cover=+ignore,inc prove -lv t 2&gt;&amp;1 | tee -a $LOG_DIR/tests.tap
+}
+
+convert_to_junit_xml() {
+ tap-to-junit-xml --input=$LOG_DIR/tests.tap --output=$LOG_DIR/tests.xml
+}
+
+make_coverage() {
+ cover -report clover
+ cover
+}
+
+measure_metrics() {
+ measureperl-checkstyle --max_sub_lines 60 --max_sub_mccabe_complexity 10 --directory lib &gt; checkstyle-result.xml
+}
+
+main() {
+ clean
+ setup
+ do_test
+ convert_to_junit_xml
+ make_coverage
+ measure_metrics
+}
+
+main</command>
+ </hudson.tasks.Shell>
+ </builders>
+ <publishers>
+ <hudson.plugins.checkstyle.CheckStylePublisher>
+ <healthy></healthy>
+ <unHealthy></unHealthy>
+ <thresholdLimit>low</thresholdLimit>
+ <pluginName>[CHECKSTYLE] </pluginName>
+ <defaultEncoding></defaultEncoding>
+ <canRunOnFailed>false</canRunOnFailed>
+ <useDeltaValues>false</useDeltaValues>
+ <thresholds>
+ <unstableTotalAll></unstableTotalAll>
+ <unstableTotalHigh></unstableTotalHigh>
+ <unstableTotalNormal></unstableTotalNormal>
+ <unstableTotalLow></unstableTotalLow>
+ <unstableNewAll></unstableNewAll>
+ <unstableNewHigh></unstableNewHigh>
+ <unstableNewNormal></unstableNewNormal>
+ <unstableNewLow></unstableNewLow>
+ <failedTotalAll></failedTotalAll>
+ <failedTotalHigh></failedTotalHigh>
+ <failedTotalNormal></failedTotalNormal>
+ <failedTotalLow></failedTotalLow>
+ <failedNewAll></failedNewAll>
+ <failedNewHigh></failedNewHigh>
+ <failedNewNormal></failedNewNormal>
+ <failedNewLow></failedNewLow>
+ </thresholds>
+ <shouldDetectModules>false</shouldDetectModules>
+ <pattern></pattern>
+ </hudson.plugins.checkstyle.CheckStylePublisher>
+ <hudson.tasks.junit.JUnitResultArchiver>
+ <testResults>logs/tests.xml</testResults>
+ <keepLongStdio>false</keepLongStdio>
+ <testDataPublishers/>
+ </hudson.tasks.junit.JUnitResultArchiver>
+ <hudson.plugins.clover.CloverPublisher>
+ <cloverReportDir></cloverReportDir>
+ <cloverReportFileName>clover.xml</cloverReportFileName>
+ <healthyTarget>
+ <methodCoverage>70</methodCoverage>
+ <conditionalCoverage>80</conditionalCoverage>
+ <statementCoverage>80</statementCoverage>
+ </healthyTarget>
+ <unhealthyTarget/>
+ <failingTarget/>
+ </hudson.plugins.clover.CloverPublisher>
+ <htmlpublisher.HtmlPublisher>
+ <reportTargets>
+ <htmlpublisher.HtmlPublisherTarget>
+ <reportName>Devel::Cover Report</reportName>
+ <reportDir>cover_db</reportDir>
+ <reportFiles>coverage.html</reportFiles>
+ <keepAll>false</keepAll>
+ <wrapperName>htmlpublisher-wrapper.html</wrapperName>
+ </htmlpublisher.HtmlPublisherTarget>
+ </reportTargets>
+ </htmlpublisher.HtmlPublisher>
+ </publishers>
+ <buildWrappers/>
+</project>
@@ -0,0 +1,43 @@
+#!/bin/bash
+#==================================
+# Configuration
+#==================================
+HOSTNAME=localhost
+PORT=8080
+JENKINS_USER=jenkins
+JENKINS_GROUP=jenkins
+JENKINS_HOME=/var/lib/jenkins
+
+#==================================
+# Main
+#==================================
+setup() {
+ install_jenkins_template
+ fetch_jenkins_cli
+ reload_jenkins_configuration
+ clean_jenkins_cli
+}
+
+install_jenkins_template() {
+ cd ${JENKINS_HOME}/jobs
+ git clone https://github.com/dann/perl-jenkins-template.git perl-jenkins-template
+ chown -R ${JENKINS_USER}:${JENKINS_GROUP} perl-jenkins-template
+}
+
+fetch_jenkins_cli() {
+ curl -LO http://${HOSTNAME}:${PORT}/jnlpJars/jenkins-cli.jar
+}
+
+jenkins_cli() {
+ java -jar jenkins-cli.jar -s http://${HOSTNAME}:${PORT} $@
+}
+
+reload_jenkins_configuration() {
+ jenkins_cli reload-configuration
+}
+
+clean_jenkins_cli() {
+ rm jenkins-cli.jar
+}
+
+setup
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+#==================================
+# Configuration
+#==================================
+HOSTNAME=localhost
+PORT=8080
+
+#==================================
+# Main
+#==================================
+JENKINS_PLUGINS=(
+git
+checkstyle
+htmlpublisher
+clover
+plot
+)
+
+PERL_MODULES=(
+Devel::Cover
+Devel::Cover::Report::Clover
+Perl::Metrics::Lite
+https://github.com/dann/tap-to-junit-xml/tarball/master
+)
+
+setup() {
+ fetch_jenkins_cli
+ install_jenkins_plugins
+ install_jenkins_related_perl_modules
+ restart_jenkins
+ clean_jenkins_cli
+}
+
+fetch_jenkins_cli() {
+ curl -LO http://${HOSTNAME}:${PORT}/jnlpJars/jenkins-cli.jar
+}
+
+jenkins_cli() {
+ java -jar jenkins-cli.jar -s http://${HOSTNAME}:${PORT} $@
+}
+
+install_jenkins_plugins() {
+ for plugin in ${JENKINS_PLUGINS[@]}
+ do
+ jenkins_cli install-plugin ${plugin}
+ done
+}
+
+install_jenkins_related_perl_modules() {
+ for module in ${PERL_MODULES[@]}
+ do
+ cpanm $module
+ done
+}
+
+restart_jenkins() {
+ jenkins_cli safe-restart
+}
+
+clean_jenkins_cli() {
+ rm jenkins-cli.jar
+}
+
+setup

0 comments on commit 2b80fee

Please sign in to comment.