require 'rexml/text' module JenkinsWorkflow class Build attr_accessor :url def initialize(url: nil) @url = url end # def create(depot_path: nil, credential:nil, job_name:nil, test_ubuntu12:nil, test_ubuntu14:nil, test_centos6:nil) workflow_script=<<-END.gsub(/^[ ]{8}/,'') node('master') { p4sync depotPath: '#{depot_path}', credential: '#{credential}' sh """#!/bin/bash --login |rvm use "2.2.3@#{job_name}" |set -e |gem install bundler |echo 'installing bundle dependencies' |bundle install |cd helix_web_services && bundle install && cd .. |cd helix_web_services_client && bundle install && cd .. |set -x |rake clean |rake test |rm -rf pkg |cd helix_web_services && rake build_version && cd .. |rake build |rake all:doc """.stripMargin() archive 'pkg/helix-web-services.tgz, **/doc-output/, **/spec-output/' } node('build-omnibus-ubuntu12') { unarchive mapping: ['**/helix-web-services.tgz': '.'] sh """#!/bin/bash --login |rvm use "2.2.3@#{job_name}" |gem install bundler |rm -rf helix-web-services* |set -e |tar xzf pkg/helix-web-services.tgz |rm -rf pkg |cd helix-web-services/packaging/omnibus-helix-web-services |bundle install --without development |export BUILD_ID=`date +'%Y-%m-%d_%H-%M-%S'` |omnibus build helix-web-services """.stripMargin() archive 'helix-web-services/packaging/omnibus-helix-web-services/pkg/helix-web-services*precise_amd64.deb' } node('test-omnibus-ubuntu12') { sh """#!/bin/bash --login |set -x |sudo service nginx stop |sudo service helix_web_services stop |sudo userdel helixwebservices |sudo rm -rf /opt/perforce/helix-web-services/home |sudo dpkg -r helix-web-services perforce-server perforce-cli perforce-cli-base perforce-p4dctl perforce-server-base nginx nginx-common nginx-full |sudo dpkg -P helix-web-services perforce-server perforce-cli perforce-cli-base perforce-p4dctl perforce-server-base nginx nginx-common nginx-full |sudo rm -rf /var/lib/perforce |sudo rm -rf /var/log/perforce |sudo rm -rf /opt/perforce |sudo rm -rf /etc/perforce/p4dctl.conf.d |sudo rm -rf /var/tmp/helix-web-services* |sudo rm -rf /var/tmp/apt* |sudo rm -rf /tmp/helix-web-services* |sudo rm -rf /etc/nginx |rm -rf helix-web-services """.stripMargin() } node('test-omnibus-ubuntu12') { unarchive mapping: ['**/helix-web-services*precise_amd64.deb': '.'] sh """#!/bin/bash --login |set -v |set -e |sudo dpkg -i helix-web-services/packaging/omnibus-helix-web-services/pkg/helix-web-services*precise_amd64.deb |sudo /opt/perforce/helix-web-services/bin/hws_configure |sudo service nginx start |sudo service helix_web_services start """.stripMargin() } node('master') { unarchive mapping: ['**/helix-web-services.tgz': '.'] sh """#!/bin/bash --login |rvm use "2.2.3@#{job_name}" |gem install bundler |set -e |echo 'installing bundle dependencies' |bundle install |cd helix_web_services && bundle install && cd .. |cd helix_web_services_client && bundle install && cd .. |set -x |rake clean |rake 'remotetest[#{test_ubuntu12}]' |mv helix_web_services_client/spec-output/helix_web_services_client_specs.html helix_web_services_client/spec-output/helix_web_services_client_specs-ubuntu12.html """.stripMargin() archive '**/spec-output/' } node('build-omnibus-ubuntu14') { unarchive mapping: ['**/helix-web-services.tgz': '.'] sh """#!/bin/bash --login |rvm use "2.2.3@#{job_name}" |gem install bundler |rm -rf helix-web-services* |set -e |tar xzf pkg/helix-web-services.tgz |rm -rf pkg |cd helix-web-services/packaging/omnibus-helix-web-services |bundle install --without development |export BUILD_ID=`date +'%Y-%m-%d_%H-%M-%S'` |omnibus build helix-web-services """.stripMargin() archive 'helix-web-services/packaging/omnibus-helix-web-services/pkg/helix-web-services*trusty_amd64.deb' } node('test-omnibus-ubuntu14') { sh """#!/bin/bash --login |set -x |sudo service nginx stop |sudo service helix_web_services stop |sudo userdel helixwebservices |sudo rm -rf /opt/perforce/helix-web-services/home |sudo dpkg -r helix-web-services perforce-server perforce-cli perforce-cli-base perforce-p4dctl perforce-server-base nginx nginx-core nginx-common |sudo dpkg -P helix-web-services perforce-server perforce-cli perforce-cli-base perforce-p4dctl perforce-server-base nginx nginx-core nginx-common |sudo rm -rf /var/lib/perforce |sudo rm -rf /var/log/perforce |sudo rm -rf /opt/perforce |sudo rm -rf /etc/perforce/p4dctl.conf.d |sudo rm -rf /var/tmp/helix-web-services* |sudo rm -rf /var/tmp/apt* |sudo rm -rf /tmp/helix-web-services* |sudo rm -rf /etc/nginx |rm -rf helix-web-services """.stripMargin() } node('test-omnibus-ubuntu14') { unarchive mapping: ['**/helix-web-services*trusty_amd64.deb': '.'] sh """#!/bin/bash --login |set -v |set -e |sudo dpkg -i helix-web-services/packaging/omnibus-helix-web-services/pkg/helix-web-services*trusty_amd64.deb |sudo /opt/perforce/helix-web-services/bin/hws_configure |sudo service helix_web_services start |sudo service nginx start |sudo service nginx stop |sudo service nginx start """.stripMargin() } node('master') { unarchive mapping: ['**/helix-web-services.tgz': '.'] sh """#!/bin/bash --login |rvm use "2.2.3@#{job_name}" |gem install bundler |set -e |echo 'installing bundle dependencies' |bundle install |cd helix_web_services && bundle install && cd .. |cd helix_web_services_client && bundle install && cd .. |set -x |rake clean |rake 'remotetest[#{test_ubuntu14}]' |mv helix_web_services_client/spec-output/helix_web_services_client_specs.html helix_web_services_client/spec-output/helix_web_services_client_specs-ubuntu14.html """.stripMargin() archive '**/spec-output/' } node('build-omnibus-centos6') { unarchive mapping: ['**/helix-web-services.tgz': '.'] sh """#!/bin/bash --login |rvm use "2.2.3@#{job_name}" |gem install bundler |rm -rf helix-web-services* |set -e |tar xzf pkg/helix-web-services.tgz |rm -rf pkg |cd helix-web-services/packaging/omnibus-helix-web-services |bundle install --without development |export BUILD_ID=`date +'%Y-%m-%d_%H-%M-%S'` |omnibus build helix-web-services """.stripMargin() archive 'helix-web-services/packaging/omnibus-helix-web-services/pkg/helix-web-services*rpm' } node('test-omnibus-centos6') { sh """#!/bin/bash --login |set -x |sudo initctl stop nginx |sudo initctl stop helix_web_services |sudo userdel helixwebservices |sudo rm -rf /opt/perforce/helix-web-services/home |sudo rpm -e helix-web-services perforce-server perforce-cli perforce-cli-base perforce-p4dctl perforce-server-base nginx |sudo rm -rf /var/lib/perforce |sudo rm -rf /var/log/perforce |sudo rm -rf /opt/perforce |sudo rm -rf /etc/perforce/p4dctl.conf.d |sudo rm -rf /var/tmp/helix-web-services* |sudo rm -rf /var/tmp/apt* |sudo rm -rf /tmp/helix-web-services* |sudo rm -rf /etc/nginx |rm -rf helix-web-services """.stripMargin() } node('test-omnibus-centos6') { unarchive mapping: ['**/helix-web-services*.rpm': '.'] sh """#!/bin/bash --login |set -v |set -e |sudo rpm -i helix-web-services/packaging/omnibus-helix-web-services/pkg/helix-web-services*.rpm |sudo /opt/perforce/helix-web-services/bin/hws_configure |sudo service nginx start |sudo initctl reload-configuration |sudo initctl start helix_web_services """.stripMargin() } node('master') { unarchive mapping: ['**/helix-web-services.tgz': '.'] sh """#!/bin/bash --login |rvm use "2.2.3@#{job_name}" |gem install bundler |set -e |echo 'installing bundle dependencies' |bundle install |cd helix_web_services && bundle install && cd .. |cd helix_web_services_client && bundle install && cd .. |set -x |rake clean |rake 'remotetest[#{test_centos6}]' |mv helix_web_services_client/spec-output/helix_web_services_client_specs.html helix_web_services_client/spec-output/helix_web_services_client_specs-centos6.html """.stripMargin() archive '**/spec-output/' } END xml =<<-END.gsub(/^[ ]{8}/, '') <flow-definition plugin="workflow-job@1.10"> <actions/> <description/> <keepDependencies>false</keepDependencies> <properties> <hudson.plugins.zentimestamp.ZenTimestampJobProperty plugin="zentimestamp@4.2"> <changeBUILDID>true</changeBUILDID> <pattern>yyyy-MM-dd_HH-mm-ss</pattern> </hudson.plugins.zentimestamp.ZenTimestampJobProperty> </properties> <logRotator class="hudson.tasks.LogRotator"> <daysToKeep>60</daysToKeep> <numToKeep>10</numToKeep> <artifactDaysToKeep>-1</artifactDaysToKeep> <artifactNumToKeep>-1</artifactNumToKeep> </logRotator> <definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps@1.10"> <script>#{REXML::Text.new(workflow_script, true, nil, false)}</script> <sandbox>false</sandbox> </definition> <triggers/> </flow-definition> END client.job.create_or_update(job_name, xml) end private def client JenkinsApi::Client.new(server_url: url, log_level: Logger::WARN) end end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#10 | 17188 | tjuricek | |||
#9 | 16330 | tjuricek |
Change the CD workflow to run the test p4d in the development tree. nginx has also been made a part of the main installation. We delete it still in the CD pipeline. |
||
#8 | 15990 | tjuricek |
Add Git Fusion tests to workflow. Revise workflow script to make it easier to follow in Groovy. |
||
#7 | 15725 | tjuricek |
Calling rake set_writable before running the omnibus build. No idea why the omnibus build is not getting the writable bit correctly set. |
||
#6 | 15675 | tjuricek |
Add basic 'publish' step for Jenkins jobs. This will archive files in a local workspace. The exact automated workflow hasn't been ironed out yet. |
||
#5 | 15662 | tjuricek |
Setup a basic daily poll for the workflow for now. The Jenkins p4 plugin doesn't seem to quite work smoothly with the workflow plugin just yet. |
||
#4 | 15661 | tjuricek |
Add some basic email notification. Note: the 'P4' Jenkins plugin doesn't seem to alter the workflow environment. This means we don't really get access to the changelist we've synced. I'm investigating, this would be nice to have. |
||
#3 | 15659 | tjuricek | Kill the currently running p4ds, since our uninstall step doesn't seem to do this on CentOS | ||
#2 | 15634 | tjuricek |
Add rules for setting up and running Centos 6. There's a strange problem coming back around with package tests again, not everything's 100% |
||
#1 | 15623 | tjuricek |
Add infrastructure project. This project should allow any team to setup a CD environment locally using VMWare products. A 'build' workflow will run tests, generate installers, etc, on a Jenkins instance configured with necessary plugins. A later 'release' workflow will initially push successful runs into the 'build/' directory of the branch in the workshop. (A 'production release' will use that data and push it into internal infrastructure for package signing and hosting.) Documentation will be written. This is a large set of files, so I wanted to submit them where my connection to the workshop server is faster. |