diff --git a/Vagrantfile b/Vagrantfile index 06a2004..66ea951 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -5,41 +5,17 @@ # vagrant command. system('./scripts/vagrant-up.sh') -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. config.vm.box = "centos/7" - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access config.vm.network "forwarded_port", guest: 8080, host: 8080, host_ip: "127.0.0.1" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - config.vm.provider "virtualbox" do |vb| vb.memory = "4096" end config.vm.provision "shell", inline: <<-SHELL - #Download Java from Oracle - [ ! -f /tmp/jdk8.rpm ] && curl -H 'Cookie: oraclelicense=accept-securebackup-cookie' -Lo /tmp/jdk8.rpm http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm - #validate the download from Oracle using official checksum - echo 'cdb016da0c509d7414ee3f0c15b2dae5092d9a77edf7915be4386d5127e8092f /tmp/jdk8.rpm' | sha256sum -c - - #Install Oracle JDK 8 - rpm -i /tmp/jdk8.rpm + # install Java + yum install -y java-1.8.0-openjdk-devel.x86_64 #install Jenkins rpm -i /vagrant/build/distributions/*.rpm #start the Jenkins daemon diff --git a/build.gradle b/build.gradle index f5f32af..5744a19 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ apply from: "${bootstrapHome}/shared.gradle" //version should be the jenkins.war version appended by .1 and increments .1 //every time there's non-jenkins.war version changes to the package. //if upgrading jenkins.war version then it should be reset to .1. -version = '2.107.3.1' +version = '2.107.3.4' description = "Built from ${tokens['PACKAGENAME']} @ ${tokens['COMMIT']}" //Jenkins war and plugin versions diff --git a/configs/job_generator.xml b/configs/job_generator.xml new file mode 100644 index 0000000..751ca20 --- /dev/null +++ b/configs/job_generator.xml @@ -0,0 +1,49 @@ + + + + + Seed Job Generator + false + + + 2 + + + https://github.com/gimp-ci/jenkins-dsl + + + + + refs/heads/master + + + false + + + + + + true + false + false + false + + false + + + jobs/*.groovy + false + false + false + false + true + true + IGNORE + IGNORE + IGNORE + JENKINS_ROOT + + + + + \ No newline at end of file diff --git a/configs/lockable-resources.groovy b/configs/lockable-resources.groovy new file mode 100644 index 0000000..9719b1d --- /dev/null +++ b/configs/lockable-resources.groovy @@ -0,0 +1,6 @@ +lockable_resources = [ + [ + name: 'update-git-cache', + description: 'Lock to prevent multiple jobs from updating the git cache at once.' + ] +] diff --git a/configs/shared-pipelines.groovy b/configs/shared-pipelines.groovy new file mode 100644 index 0000000..3e05f15 --- /dev/null +++ b/configs/shared-pipelines.groovy @@ -0,0 +1,12 @@ +pipeline_shared_libraries = [ + 'GIMP Pipeline Library': [ + 'defaultVersion': 'master', + 'implicit': true, + 'allowVersionOverride': false, + 'includeInChangesets': true, + 'scm': [ + 'remote': 'https://github.com/gimp-ci/jenkins-dsl' + ] + ] +] + diff --git a/configs/view_build_pipelines.xml b/configs/view_build_pipelines.xml new file mode 100644 index 0000000..88bac44 --- /dev/null +++ b/configs/view_build_pipelines.xml @@ -0,0 +1,27 @@ + + + Build Pipelines + false + false + + + + + + + includeMatched + org.jenkinsci.plugins.pipeline.multibranch.defaults.PipelineMultiBranchDefaultsProject + + + + + + + + + + + + [^_].* + false + \ No newline at end of file diff --git a/configs/view_maintenance.xml b/configs/view_maintenance.xml new file mode 100644 index 0000000..cd6686b --- /dev/null +++ b/configs/view_maintenance.xml @@ -0,0 +1,22 @@ + + + Maintenance + false + false + + + + + + + + + + + + + + + ^_.* + false + \ No newline at end of file diff --git a/configs/view_status_overview.xml b/configs/view_status_overview.xml new file mode 100644 index 0000000..afb0be0 --- /dev/null +++ b/configs/view_status_overview.xml @@ -0,0 +1,52 @@ + + + Status Overview + false + false + + + + + + + includeMatched + org.jenkinsci.plugins.workflow.job.WorkflowJob + + + + true + false + false + false + 50% + 50% + + + + + dashboard_portlet_8806 + Jobs Grid + 2 + true + + + dashboard_portlet_9728 + Unstable Jobs + false + true + + + dashboard_portlet_30498 + Latest builds + 5 + + + dashboard_portlet_25458 + Stay Informed + <div style="margin:1em" align="right"><a href="/blue/pipelines"><img alt="Open Blue Ocean" src="/static/8316b8ea/plugin/blueocean-rest-impl/images/48x48/blueocean.png" height="16" border="0" width="16"> Beautifully Rendered Pipelines</a><span style="padding-left:1em"><a href="/legend">Legend</a></span><span style="padding-left:1em"><a href="/rssAll"><img alt="Feed" src="/static/a56acb97/images/atom.gif" height="16" border="0" width="16"> RSS for all</a></span><span style="padding-left:1em"><a href="/rssFailed"><img alt="Feed" src="/static/a56acb97/images/atom.gif" height="16" border="0" width="16"> RSS for failures</a></span><span style="padding-left:1em"><a href="/rssLatest"><img alt="Feed" src="/static/a56acb97/images/atom.gif" height="16" border="0" width="16"> RSS for just latest builds</a></span></div> + <div style="margin:1em" align="right"><a href="/blue/pipelines"><img alt="Open Blue Ocean" src="/static/8316b8ea/plugin/blueocean-rest-impl/images/48x48/blueocean.png" height="16" border="0" width="16"> Beautifully Rendered Pipelines</a><span style="padding-left:1em"><a href="/legend">Legend</a></span><span style="padding-left:1em"><a href="/rssAll"><img alt="Feed" src="/static/a56acb97/images/atom.gif" height="16" border="0" width="16"> RSS for all</a></span><span style="padding-left:1em"><a href="/rssFailed"><img alt="Feed" src="/static/a56acb97/images/atom.gif" height="16" border="0" width="16"> RSS for failures</a></span><span style="padding-left:1em"><a href="/rssLatest"><img alt="Feed" src="/static/a56acb97/images/atom.gif" height="16" border="0" width="16"> RSS for just latest builds</a></span></div> + HTML + + + + \ No newline at end of file diff --git a/custom-plugins.txt b/custom-plugins.txt new file mode 100644 index 0000000..06ffdd7 --- /dev/null +++ b/custom-plugins.txt @@ -0,0 +1,17 @@ +# THESE BETA PLUGINS ARE REQUIRED BECAUSE OF +# https://github.com/gimp-ci/jenkins-dsl/issues/1 +# Plugins were built in the following environment: +# Ubuntu 16.04.4 LTS +# Linux 4.13.0-41-generic x86_64 +# java version "1.8.0_131" +# Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T11:49:05-08:00) +# Default locale: en_US, platform encoding: UTF-8 +# Build Command: +# mvn clean package install + +# built from https://github.com/jenkinsci/git-client-plugin @ b4130534522ba299be8125b416e4237612d5f289 +org.jenkins-ci.plugins:git-client:3.0.0-beta3-SNAPSHOT@hpi + +# built from https://github.com/jenkinsci/git-plugin @ 17705db2da2a01a4680a28ccddd494e4ff6800c8 +# ref: https://github.com/jenkinsci/git-plugin/pull/595 +org.jenkins-ci.plugins:git:4.0.0-SNAPSHOT@hpi diff --git a/dependencies.gradle b/dependencies.gradle index 310636b..b8fe7f0 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -3,84 +3,113 @@ dependencies { getjenkins 'org.jenkins-ci.main:jenkins-war:2.107.3@war' //custom plugins (if any) provided by custom-plugins.txt; format: G:A:V@hpi or G:A:V@jpi + getplugins 'org.jenkins-ci.plugins:git-client:3.0.0-beta3-SNAPSHOT@hpi' + getplugins 'org.jenkins-ci.plugins:git:4.0.0-SNAPSHOT@hpi' //get plugins getplugins 'com.coravy.hudson.plugins.github:github:1.29.0@hpi' - getplugins 'net.hurstfrost.jenkins:avatar:1.2@hpi' + getplugins 'io.jenkins.blueocean:blueocean-bitbucket-pipeline:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-commons:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-config:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-core-js:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-dashboard:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-events:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-git-pipeline:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-github-pipeline:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-i18n:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-jira:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-jwt:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-personalization:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-pipeline-api-impl:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-pipeline-editor:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-pipeline-scm-api:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-rest-impl:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-rest:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean-web:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:blueocean:1.5.0@hpi' + getplugins 'io.jenkins.blueocean:jenkins-design-language:1.5.0@hpi' + getplugins 'org.6wind.jenkins:lockable-resources:2.2@hpi' getplugins 'org.jenkins-ci.main:maven-plugin:3.1.2@hpi' - getplugins 'org.jenkins-ci.plugins.icon-shim:icon-shim:2.0.3@hpi' + getplugins 'org.jenkins-ci.plugins.pipeline-stage-view:pipeline-rest-api:2.10@hpi' + getplugins 'org.jenkins-ci.plugins.pipeline-stage-view:pipeline-stage-view:2.10@hpi' + getplugins 'org.jenkins-ci.plugins.workflow:workflow-aggregator:2.5@hpi' getplugins 'org.jenkins-ci.plugins.workflow:workflow-api:2.27@hpi' + getplugins 'org.jenkins-ci.plugins.workflow:workflow-basic-steps:2.7@hpi' + getplugins 'org.jenkins-ci.plugins.workflow:workflow-cps-global-lib:2.9@hpi' getplugins 'org.jenkins-ci.plugins.workflow:workflow-cps:2.53@hpi' + getplugins 'org.jenkins-ci.plugins.workflow:workflow-durable-task-step:2.19@hpi' getplugins 'org.jenkins-ci.plugins.workflow:workflow-job:2.21@hpi' + getplugins 'org.jenkins-ci.plugins.workflow:workflow-multibranch:2.19@hpi' getplugins 'org.jenkins-ci.plugins.workflow:workflow-scm-step:2.6@hpi' - getplugins 'org.jenkins-ci.plugins.workflow:workflow-step-api:2.14@hpi' + getplugins 'org.jenkins-ci.plugins.workflow:workflow-step-api:2.15@hpi' getplugins 'org.jenkins-ci.plugins.workflow:workflow-support:2.18@hpi' - getplugins 'org.jenkins-ci.plugins:all-changes:1.5@hpi' - getplugins 'org.jenkins-ci.plugins:ant:1.8@hpi' getplugins 'org.jenkins-ci.plugins:antisamy-markup-formatter:1.5@hpi' getplugins 'org.jenkins-ci.plugins:apache-httpcomponents-client-4-api:4.5.5-2.0@hpi' + getplugins 'org.jenkins-ci.plugins:authentication-tokens:1.3@hpi' + getplugins 'org.jenkins-ci.plugins:badge:1.4@hpi' + getplugins 'org.jenkins-ci.plugins:blueocean-autofavorite:1.2.2@hpi' + getplugins 'org.jenkins-ci.plugins:blueocean-display-url:2.2.0@hpi' getplugins 'org.jenkins-ci.plugins:bouncycastle-api:2.16.2@hpi' - getplugins 'org.jenkins-ci.plugins:build-blocker-plugin:1.7.3@hpi' - getplugins 'org.jenkins-ci.plugins:clamav:0.3@hpi' + getplugins 'org.jenkins-ci.plugins:branch-api:2.0.20@hpi' + getplugins 'org.jenkins-ci.plugins:build-timeout:1.19@hpi' + getplugins 'org.jenkins-ci.plugins:cloudbees-bitbucket-branch-source:2.2.11@hpi' + getplugins 'org.jenkins-ci.plugins:cloudbees-folder:6.4@hpi' getplugins 'org.jenkins-ci.plugins:command-launcher:1.2@hpi' - getplugins 'org.jenkins-ci.plugins:conditional-buildstep:1.3.6@hpi' - getplugins 'org.jenkins-ci.plugins:console-column-plugin:1.5@hpi' + getplugins 'org.jenkins-ci.plugins:config-file-provider:2.18@hpi' getplugins 'org.jenkins-ci.plugins:copyartifact:1.39.1@hpi' + getplugins 'org.jenkins-ci.plugins:credentials-binding:1.16@hpi' getplugins 'org.jenkins-ci.plugins:credentials:2.1.16@hpi' - getplugins 'org.jenkins-ci.plugins:cvs:2.14@hpi' getplugins 'org.jenkins-ci.plugins:dashboard-view:2.9.11@hpi' - getplugins 'org.jenkins-ci.plugins:description-column-plugin:1.3@hpi' - getplugins 'org.jenkins-ci.plugins:description-setter:1.10@hpi' - getplugins 'org.jenkins-ci.plugins:disk-usage:0.28@hpi' getplugins 'org.jenkins-ci.plugins:display-url-api:2.2.0@hpi' - getplugins 'org.jenkins-ci.plugins:external-monitor-job:1.7@hpi' - getplugins 'org.jenkins-ci.plugins:extra-columns:1.18@hpi' - getplugins 'org.jenkins-ci.plugins:git-client:2.7.2@hpi' - getplugins 'org.jenkins-ci.plugins:git:3.9.0@hpi' + getplugins 'org.jenkins-ci.plugins:docker-commons:1.13@hpi' + getplugins 'org.jenkins-ci.plugins:docker-workflow:1.17@hpi' + getplugins 'org.jenkins-ci.plugins:durable-task:1.22@hpi' + getplugins 'org.jenkins-ci.plugins:email-ext:2.62@hpi' + getplugins 'org.jenkins-ci.plugins:embeddable-build-status:1.9@hpi' + getplugins 'org.jenkins-ci.plugins:git-server:1.7@hpi' getplugins 'org.jenkins-ci.plugins:github-api:1.90@hpi' - getplugins 'org.jenkins-ci.plugins:greenballs:1.15@hpi' + getplugins 'org.jenkins-ci.plugins:github-branch-source:2.3.4@hpi' + getplugins 'org.jenkins-ci.plugins:groovy:2.0@hpi' + getplugins 'org.jenkins-ci.plugins:handy-uri-templates-2-api:2.1.6-1.0@hpi' + getplugins 'org.jenkins-ci.plugins:htmlpublisher:1.16@hpi' getplugins 'org.jenkins-ci.plugins:jackson2-api:2.8.11.2@hpi' getplugins 'org.jenkins-ci.plugins:javadoc:1.4@hpi' - getplugins 'org.jenkins-ci.plugins:jobConfigHistory:2.18@hpi' + getplugins 'org.jenkins-ci.plugins:jira:3.0.0@hpi' + getplugins 'org.jenkins-ci.plugins:job-dsl:1.69@hpi' getplugins 'org.jenkins-ci.plugins:jsch:0.1.54.2@hpi' getplugins 'org.jenkins-ci.plugins:junit:1.24@hpi' - getplugins 'org.jenkins-ci.plugins:ldap:1.20@hpi' - getplugins 'org.jenkins-ci.plugins:log-parser:2.0@hpi' getplugins 'org.jenkins-ci.plugins:mailer:1.21@hpi' - getplugins 'org.jenkins-ci.plugins:mapdb-api:1.0.9.0@hpi' getplugins 'org.jenkins-ci.plugins:matrix-auth:2.2@hpi' getplugins 'org.jenkins-ci.plugins:matrix-project:1.13@hpi' - getplugins 'org.jenkins-ci.plugins:pam-auth:1.3@hpi' - getplugins 'org.jenkins-ci.plugins:parameterized-trigger:2.35.2@hpi' + getplugins 'org.jenkins-ci.plugins:mercurial:2.3@hpi' + getplugins 'org.jenkins-ci.plugins:pipeline-build-step:2.7@hpi' + getplugins 'org.jenkins-ci.plugins:pipeline-graph-analysis:1.6@hpi' + getplugins 'org.jenkins-ci.plugins:pipeline-input-step:2.8@hpi' + getplugins 'org.jenkins-ci.plugins:pipeline-milestone-step:1.3.1@hpi' + getplugins 'org.jenkins-ci.plugins:pipeline-multibranch-defaults:1.1@hpi' + getplugins 'org.jenkins-ci.plugins:pipeline-stage-step:2.3@hpi' getplugins 'org.jenkins-ci.plugins:plain-credentials:1.4@hpi' + getplugins 'org.jenkins-ci.plugins:pubsub-light:1.12@hpi' getplugins 'org.jenkins-ci.plugins:rich-text-publisher-plugin:1.4@hpi' - getplugins 'org.jenkins-ci.plugins:role-strategy:2.8.0@hpi' - getplugins 'org.jenkins-ci.plugins:run-condition:1.0@hpi' - getplugins 'org.jenkins-ci.plugins:saferestart:0.3@hpi' getplugins 'org.jenkins-ci.plugins:scm-api:2.2.7@hpi' + getplugins 'org.jenkins-ci.plugins:scm-filter-branch-pr:0.3@hpi' getplugins 'org.jenkins-ci.plugins:script-security:1.44@hpi' - getplugins 'org.jenkins-ci.plugins:shelve-project-plugin:1.5@hpi' - getplugins 'org.jenkins-ci.plugins:sidebar-link:1.9.1@hpi' - getplugins 'org.jenkins-ci.plugins:ssh-agent:1.15@hpi' + getplugins 'org.jenkins-ci.plugins:sse-gateway:1.15@hpi' getplugins 'org.jenkins-ci.plugins:ssh-credentials:1.13@hpi' - getplugins 'org.jenkins-ci.plugins:ssh-slaves:1.26@hpi' getplugins 'org.jenkins-ci.plugins:structs:1.14@hpi' - getplugins 'org.jenkins-ci.plugins:subversion:2.10.5@hpi' - getplugins 'org.jenkins-ci.plugins:text-finder:1.10@hpi' getplugins 'org.jenkins-ci.plugins:token-macro:2.5@hpi' - getplugins 'org.jenkins-ci.plugins:translation:1.16@hpi' + getplugins 'org.jenkins-ci.plugins:variant:1.1@hpi' + getplugins 'org.jenkins-ci.plugins:view-job-filters:1.27@hpi' getplugins 'org.jenkins-ci.plugins:windows-slaves:1.3.1@hpi' getplugins 'org.jenkins-ci.ui:ace-editor:1.1@hpi' + getplugins 'org.jenkins-ci.ui:handlebars:1.1.1@hpi' getplugins 'org.jenkins-ci.ui:jquery-detached:1.2.1@hpi' - getplugins 'org.jenkinsci.plugins:doclinks:0.6.1@hpi' - getplugins 'org.jvnet.hudson.plugins:analysis-collector:1.52@hpi' - getplugins 'org.jvnet.hudson.plugins:analysis-core:1.95@hpi' - getplugins 'org.jvnet.hudson.plugins:checkstyle:3.50@hpi' - getplugins 'org.jvnet.hudson.plugins:dry:2.50@hpi' - getplugins 'org.jvnet.hudson.plugins:extended-read-permission:2.0@hpi' - getplugins 'org.jvnet.hudson.plugins:instant-messaging:1.35@hpi' - getplugins 'org.jvnet.hudson.plugins:ircbot:2.30@hpi' - getplugins 'org.jvnet.hudson.plugins:monitoring:1.72.0@hpi' - getplugins 'org.jvnet.hudson.plugins:thinBackup:1.9@hpi' - getplugins 'org.jvnet.hudson.plugins:warnings:4.66@hpi' + getplugins 'org.jenkins-ci.ui:momentjs:1.1.1@hpi' + getplugins 'org.jenkinsci.plugins:pipeline-model-api:1.2.9@hpi' + getplugins 'org.jenkinsci.plugins:pipeline-model-declarative-agent:1.1.1@hpi' + getplugins 'org.jenkinsci.plugins:pipeline-model-definition:1.2.9@hpi' + getplugins 'org.jenkinsci.plugins:pipeline-model-extensions:1.2.9@hpi' + getplugins 'org.jenkinsci.plugins:pipeline-stage-tags-metadata:1.2.9@hpi' + getplugins 'org.jvnet.hudson.plugins:favorite:2.3.2@hpi' + getplugins 'org.jvnet.hudson.plugins:groovy-postbuild:2.4.1@hpi' } diff --git a/jenkins-bootstrap-shared b/jenkins-bootstrap-shared index d1683a4..372047b 160000 --- a/jenkins-bootstrap-shared +++ b/jenkins-bootstrap-shared @@ -1 +1 @@ -Subproject commit d1683a42e80f0c35ecbf884e10efe0158b8527f6 +Subproject commit 372047b21e4e139365bbb57f07c4c3f7dc0419c0 diff --git a/jenkins_bootstrap.sh b/jenkins_bootstrap.sh index 5f9ee09..491c33b 100755 --- a/jenkins_bootstrap.sh +++ b/jenkins_bootstrap.sh @@ -1,2 +1,18 @@ #!/bin/bash source jenkins-bootstrap-shared/jenkins_bootstrap.sh + +create_view --view-name 'Status Overview' --xml-data ./configs/view_status_overview.xml +create_view --view-name 'Maintenance' --xml-data ./configs/view_maintenance.xml +create_view --view-name 'Build Pipelines' --xml-data ./configs/view_build_pipelines.xml +create_job --job-name '_job_generator' --xml-data ./configs/job_generator.xml +#disable job dsl script security +jenkins_console -s "${SCRIPT_LIBRARY_PATH}/configure-job-dsl-security.groovy" +#only enable JNLP4 agent protocol +jenkins_console -s "${SCRIPT_LIBRARY_PATH}/configure-jnlp-agent-protocols.groovy" +#global Jenkinsfile +jenkins_console -s "./scripts/configure-global-jenkinsfile-gimp.groovy" +#set markup formatter to HTML +jenkins_console -s "${SCRIPT_LIBRARY_PATH}/configure-markup-formatter.groovy" +#configure shared pipeline library +jenkins_console -s ./configs/shared-pipelines.groovy -s "${SCRIPT_LIBRARY_PATH}"/configure-pipeline-global-shared-libraries.groovy +jenkins_console -s ./configs/lockable-resources.groovy -s "${SCRIPT_LIBRARY_PATH}"/configure-lockable-resources.groovy diff --git a/scripts/configure-global-jenkinsfile-gimp.groovy b/scripts/configure-global-jenkinsfile-gimp.groovy new file mode 100644 index 0000000..e63f021 --- /dev/null +++ b/scripts/configure-global-jenkinsfile-gimp.groovy @@ -0,0 +1,53 @@ +/* + Copyright 2015-2018 Sam Gleske - https://github.com/samrocketman/jenkins-bootstrap-jervis + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +/* + Configure a global Jenkinsfile within the Config File Provider plugin. This + is meant to be used by the Pipeline Multibranch Defaults Plugin. + */ + +import jenkins.model.Jenkins +import org.jenkinsci.plugins.configfiles.GlobalConfigFiles +import org.jenkinsci.plugins.configfiles.groovy.GroovyScript + +//bindings +script_approval = Jenkins.instance.getExtensionList('org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval')[0] +config_files = Jenkins.instance.getExtensionList(GlobalConfigFiles)[0] + +jenkinsfile_script = ''' +gimpBuildPipeline() +'''.trim() + +if(!config_files.getById('Jenkinsfile')) { + //create global config + GroovyScript new_config = new GroovyScript('Jenkinsfile', 'Global Jenkinsfile', '', jenkinsfile_script) + config_files.save(new_config) + println 'Configured global Jenkinsfile.' +} +else { + println 'Nothing changed. Global Jenkinsfile already configured.' +} + +//approve Jenkinsfile script for execution +String hash = script_approval.hash(jenkinsfile_script, 'groovy') +if(hash in script_approval.approvedScriptHashes) { + println 'Nothing changed. Global Jenkinsfile script already approved.' +} +else { + script_approval.approveScript(hash) + script_approval.save() + println 'Global Jenkinsfile script has been approved in script security.' +}