Module: Autoproj::Jenkins

Defined in:
lib/autoproj/jenkins.rb,
lib/autoproj/jenkins/server.rb,
lib/autoproj/jenkins/updater.rb,
lib/autoproj/jenkins/version.rb,
lib/autoproj/jenkins/exceptions.rb,
lib/autoproj/jenkins/relativize.rb,
lib/autoproj/jenkins/credentials.rb,
lib/autoproj/jenkins/render_template.rb

Defined Under Namespace

Classes: Credentials, Relativize, Server, TemplateRenderingContext, UnhandledVCS, UnknownTemplateParameter, UnusedTemplateParameters, Updater

Constant Summary collapse

VERSION =
"0.3.14"

Class Method Summary collapse

Class Method Details

.has_template?(template_name) ⇒ Boolean

Test if a template with the given basename exists

Returns:



71
72
73
# File 'lib/autoproj/jenkins/render_template.rb', line 71

def self.has_template?(template_name)
    (template_path + "#{template_name}.erb").exist?
end

.render_template(template_name, allow_unused: false, template_path: self.template_path, **parameters) ⇒ String

Create a template rendering context for the given parameters

Parameters:

  • the name of the template to be rendered, without the .erb extension

  • the template parameters

  • (defaults to: self.template_path)

    where the templates are located on disk

Returns:



82
83
84
85
86
87
88
89
90
91
# File 'lib/autoproj/jenkins/render_template.rb', line 82

def self.render_template(template_name, allow_unused: false, template_path: self.template_path, **parameters)
    context = TemplateRenderingContext.new(template_path, allow_unused: allow_unused, **parameters)
    template_path = template_path + "#{template_name}.erb"
    template = ERB.new(template_path.read)
    template.filename = template_path.to_s
    b = context.instance_eval { Kernel.binding }
    result = template.result(b)
    context.__verify
    result
end

.template_pathObject

The path to autoproj-jenkins templates



66
67
68
# File 'lib/autoproj/jenkins/render_template.rb', line 66

def self.template_path
    Pathname.new(__dir__) + "templates"
end

.vcs_supported?(vcs) ⇒ Boolean

Returns true if the given VCS type is supported

Parameters:

  • the VCS type (e.g. 'git')

Returns:



5
6
7
# File 'lib/autoproj/jenkins/updater.rb', line 5

def self.vcs_supported?(vcs)
    Autoproj::Jenkins.has_template?("import-#{vcs}.pipeline")
end