-
Notifications
You must be signed in to change notification settings - Fork 3
/
_jenkins_jobs.rb
63 lines (53 loc) · 1.87 KB
/
_jenkins_jobs.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
=begin
#<
Defines the Jenkins jobs
#>
=end
#######################
# JobDSL Seed
#######################
chef_repo_jobdsl_job = File.join(Chef::Config[:file_cache_path], "chef_repo_seed.xml")
template chef_repo_jobdsl_job do
source "jenkins-jobs/jobdsl/chef_repo.xml.erb"
notifies :create, "jenkins_job[chef-repo-seed]", :immediately
notifies :build, "jenkins_job[chef-repo-seed]"
end
jenkins_job "chef-repo-seed" do
action :nothing
config chef_repo_jobdsl_job
end
directory "#{node['jenkins']['master']['home']}/jobs/chef-repo-seed/workspace/" do
action :create
owner node['jenkins']['master']['user']
group node['jenkins']['master']['group']
mode '0755'
end
template "#{node['jenkins']['master']['home']}/jobs/chef-repo-seed/workspace/chef_repo.groovy" do
source "jenkins-jobs/jobdsl/chef_repo.groovy.erb"
owner node['jenkins']['master']['user']
group node['jenkins']['master']['group']
notifies :build, "jenkins_job[chef-repo-seed]"
end
#######################
# Workflow Global Library
#######################
jenkins_script 'global-library-chefci' do
command <<-EOH.gsub(/^ {4}/, '')
import jenkins.model.Jenkins
import org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever;
import org.jenkinsci.plugins.workflow.libs.LibraryConfiguration;
import jenkins.plugins.git.GitSCMSource;
SCMSourceRetriever retriever = new SCMSourceRetriever(new GitSCMSource(
"global-library-chefci",
"https://github.com/TYPO3-infrastructure/jenkins-pipeline-global-library-chefci/",
null,
"*",
"",
false))
LibraryConfiguration pipeline = new LibraryConfiguration("chefci", retriever)
pipeline.setDefaultVersion('master')
pipeline.setImplicit(true)
Jenkins.getInstance().getDescriptor("org.jenkinsci.plugins.workflow.libs.GlobalLibraries").get()
.setLibraries([pipeline])
EOH
end