-
Notifications
You must be signed in to change notification settings - Fork 0
/
parameters.html
97 lines (81 loc) · 16.4 KB
/
parameters.html
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<html><head><title>Orkestra: Parameters</title><meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="author" content="tech.orkestra" /><meta name="description" content="Functional DevOps with Scala and Kubernetes" /><meta name="og:image" content="/img/poster.png" /><meta name="og:title" content="Orkestra: Parameters" /><meta name="og:site_name" content="Orkestra" /><meta name="og:url" content="https://orkestra.tech" /><meta name="og:type" content="website" /><meta name="og:description" content="Functional DevOps with Scala and Kubernetes" /><link rel="icon" type="image/png" href="/img/favicon.png" /><meta name="twitter:title" content="Orkestra: Parameters" /><meta name="twitter:image" content="https://orkestra.techimg/poster.png" /><meta name="twitter:description" content="Functional DevOps with Scala and Kubernetes" /><meta name="twitter:card" content="summary_large_image" /><link rel="icon" type="image/png" sizes="16x16" href="/img/favicon16x16.png" /><link rel="icon" type="image/png" sizes="24x24" href="/img/favicon24x24.png" /><link rel="icon" type="image/png" sizes="32x32" href="/img/favicon32x32.png" /><link rel="icon" type="image/png" sizes="48x48" href="/img/favicon48x48.png" /><link rel="icon" type="image/png" sizes="57x57" href="/img/favicon57x57.png" /><link rel="icon" type="image/png" sizes="60x60" href="/img/favicon60x60.png" /><link rel="icon" type="image/png" sizes="64x64" href="/img/favicon64x64.png" /><link rel="icon" type="image/png" sizes="70x70" href="/img/favicon70x70.png" /><link rel="icon" type="image/png" sizes="72x72" href="/img/favicon72x72.png" /><link rel="icon" type="image/png" sizes="76x76" href="/img/favicon76x76.png" /><link rel="icon" type="image/png" sizes="96x96" href="/img/favicon96x96.png" /><link rel="icon" type="image/png" sizes="114x114" href="/img/favicon114x114.png" /><link rel="icon" type="image/png" sizes="120x120" href="/img/favicon120x120.png" /><link rel="icon" type="image/png" sizes="128x128" href="/img/favicon128x128.png" /><link rel="icon" type="image/png" sizes="144x144" href="/img/favicon144x144.png" /><link rel="icon" type="image/png" sizes="150x150" href="/img/favicon150x150.png" /><link rel="icon" type="image/png" sizes="152x152" href="/img/favicon152x152.png" /><link rel="icon" type="image/png" sizes="196x196" href="/img/favicon196x196.png" /><link rel="icon" type="image/png" sizes="310x310" href="/img/favicon310x310.png" /><link rel="icon" type="image/png" sizes="310x150" href="/img/favicon310x150.png" /><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" /><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" /><link rel="stylesheet" href="/highlight/styles/atom-one-light.css" /><link rel="stylesheet" href="/css/style.css" /><link rel="stylesheet" href="/css/palette.css" /><link rel="stylesheet" href="/css/codemirror.css" /><link rel="stylesheet" href="/css/override.css" /></head><body class="docs"><div id="wrapper"><div id="sidebar-wrapper"><ul id="sidebar" class="sidebar-nav"><li class="sidebar-brand"><a href="/" class="brand"><div class="brand-wrapper"><span>Orkestra</span></div></a></li> <li><a href="/jobsboards.html" class="">Jobs & Boards</a></li> <li><a href="/config.html" class="">Config</a></li> <li><a href="/parameters.html" class=" active ">Parameters</a></li> <li><a href="/stages.html" class="">Stages</a></li> <li><a href="/shells.html" class="">Shell scripts</a></li> <li><a href="/directories.html" class="">Directories</a></li> <li><a href="/secrets.html" class="">Secrets</a></li> <li><a href="/triggers.html" class="">Triggering jobs</a></li> <li><a href="/runid.html" class="">RunId</a></li> <li><a href="/containers.html" class="">Containers</a></li> <li><a href="/plugins" class="">Plugins</a> <ul class="sub_section"> <li><a href="/plugins/github.html" class="">Github</a></li> <li><a href="/plugins/cron.html" class="">Cron jobs</a></li> <li><a href="/plugins/locking.html" class="">Locking</a></li></ul></li></ul></div><div id="page-content-wrapper"><div class="nav"><div class="container-fluid"><div class="row"><div class="col-lg-12"><div class="action-menu pull-left clearfix"><a href="#menu-toggle" id="menu-toggle"><i class="fa fa-bars" aria-hidden="true"></i></a></div><ul class="pull-right"><li id="gh-eyes-item" class="hidden-xs"><a href="https://github.com/Orkestra-Tech/orkestra"><i class="fa fa-eye"></i><span>WATCH<span id="eyes" class="label label-default">--</span></span></a></li><li id="gh-stars-item" class="hidden-xs"><a href="https://github.com/Orkestra-Tech/orkestra"><i class="fa fa-star-o"></i><span>STARS<span id="stars" class="label label-default">--</span></span></a></li><li><a href="#" onclick="shareSiteTwitter('Orkestra Functional DevOps with Scala and Kubernetes');"><i class="fa fa-twitter"></i></a></li><li><a href="#" onclick="shareSiteFacebook('Orkestra Functional DevOps with Scala and Kubernetes');"><i class="fa fa-facebook"></i></a></li><li><a href="#" onclick="shareSiteGoogle();"><i class="fa fa-google-plus"></i></a></li></ul></div></div></div></div><div id="content" data-github-owner="Orkestra-Tech" data-github-repo="orkestra"><div class="content-wrapper"><section><h1 id="parameters">Parameters</h1>
<p>If you’d like to pass parameters to a job you can add the corresponding UI elements, here is an example:</p>
<div class="language-scala highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">import</span> <span class="nn">tech.orkestra.Dsl._</span>
<span class="k">import</span> <span class="nn">tech.orkestra.board._</span>
<span class="k">import</span> <span class="nn">tech.orkestra.job._</span>
<span class="k">import</span> <span class="nn">tech.orkestra.model.JobId</span>
<span class="k">import</span> <span class="nn">tech.orkestra.parameter._</span>
<span class="c1">// Note that the signature of the function now contains the types of the parameters
</span><span class="k">lazy</span> <span class="k">val</span> <span class="n">parametersJobBoard</span> <span class="k">=</span> <span class="nc">JobBoard</span><span class="o">[(</span><span class="kt">String</span>, <span class="kt">Boolean</span><span class="o">)</span> <span class="k">=></span> <span class="kt">Unit</span><span class="o">](</span><span class="nc">JobId</span><span class="o">(</span><span class="s">"parameters"</span><span class="o">),</span> <span class="s">"Parameters"</span><span class="o">)(</span>
<span class="nc">Input</span><span class="o">[</span><span class="kt">String</span><span class="o">](</span><span class="s">"Git ref"</span><span class="o">),</span>
<span class="nc">Checkbox</span><span class="o">(</span><span class="s">"Run tests?"</span><span class="o">)</span>
<span class="o">)</span>
<span class="k">lazy</span> <span class="k">val</span> <span class="n">parametersJob</span> <span class="k">=</span> <span class="nc">Job</span><span class="o">(</span><span class="n">parametersJobBoard</span><span class="o">)</span> <span class="o">{</span> <span class="k">implicit</span> <span class="n">workDir</span> <span class="k">=></span> <span class="o">(</span><span class="n">gitRef</span><span class="o">,</span> <span class="n">runTests</span><span class="o">)</span> <span class="k">=></span>
<span class="n">println</span><span class="o">(</span><span class="n">s</span><span class="s">"Building app for Git ref $gitRef${if (runTests) "</span> <span class="n">and</span> <span class="n">running</span> <span class="n">tests</span><span class="s">" else ""}"</span><span class="o">)</span>
<span class="o">}</span>
</code></pre></div></div>
<p><img alt="Parameters" srcset="img/parameters.png 2x" /></p>
<h2 id="select">Select</h2>
<p>As you can see on the above screenshot it also supports drop-down lists via <a href="https://github.com/lloydmeta/enumeratum">Enumeratum</a>,
so let’s try that out!<br />
First of all we need to add the <a href="https://github.com/lloydmeta/enumeratum">Enumeratum</a> dependency in <code class="highlighter-rouge">build.sbt</code>:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>// Not the triple %%% to import the cross compiled JS/JVM version
libraryDependencies += "com.beachape" %%% "enumeratum" % "Enumeratum version"
</code></pre></div></div>
<p>Then we can refine the previous code to include the drop-down:</p>
<div class="language-scala highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">import</span> <span class="nn">tech.orkestra.Dsl._</span>
<span class="k">import</span> <span class="nn">tech.orkestra.board._</span>
<span class="k">import</span> <span class="nn">tech.orkestra.job._</span>
<span class="k">import</span> <span class="nn">tech.orkestra.model.JobId</span>
<span class="k">import</span> <span class="nn">tech.orkestra.parameter._</span>
<span class="k">import</span> <span class="nn">enumeratum._</span>
<span class="c1">// We declare the enum
</span><span class="k">sealed</span> <span class="k">trait</span> <span class="nc">Environment</span> <span class="k">extends</span> <span class="nc">EnumEntry</span>
<span class="k">object</span> <span class="nc">Environment</span> <span class="k">extends</span> <span class="nc">Enum</span><span class="o">[</span><span class="kt">Environment</span><span class="o">]</span> <span class="o">{</span>
<span class="k">case</span> <span class="k">object</span> <span class="nc">Prod</span> <span class="k">extends</span> <span class="nc">Environment</span>
<span class="k">case</span> <span class="k">object</span> <span class="nc">Staging</span> <span class="k">extends</span> <span class="nc">Environment</span>
<span class="k">case</span> <span class="k">object</span> <span class="nc">QA</span> <span class="k">extends</span> <span class="nc">Environment</span>
<span class="k">val</span> <span class="n">values</span> <span class="k">=</span> <span class="n">findValues</span>
<span class="o">}</span>
<span class="k">lazy</span> <span class="k">val</span> <span class="n">parametersJobBoard</span> <span class="k">=</span> <span class="nc">JobBoard</span><span class="o">[(</span><span class="kt">String</span>, <span class="kt">Boolean</span>, <span class="kt">Environment</span><span class="o">)</span> <span class="k">=></span> <span class="kt">Unit</span><span class="o">](</span><span class="nc">JobId</span><span class="o">(</span><span class="s">"parameters"</span><span class="o">),</span> <span class="s">"Parameters"</span><span class="o">)(</span>
<span class="nc">Input</span><span class="o">[</span><span class="kt">String</span><span class="o">](</span><span class="s">"Git ref"</span><span class="o">),</span>
<span class="nc">Checkbox</span><span class="o">(</span><span class="s">"Run tests?"</span><span class="o">),</span>
<span class="nc">Select</span><span class="o">(</span><span class="s">"Deploy on"</span><span class="o">,</span> <span class="nc">Environment</span><span class="o">,</span> <span class="nc">Option</span><span class="o">(</span><span class="nc">Environment</span><span class="o">.</span><span class="nc">QA</span><span class="o">))</span>
<span class="o">)</span>
<span class="k">lazy</span> <span class="k">val</span> <span class="n">parametersJob</span> <span class="k">=</span> <span class="nc">Job</span><span class="o">(</span><span class="n">parametersJobBoard</span><span class="o">)</span> <span class="o">{</span> <span class="k">implicit</span> <span class="n">workDir</span> <span class="k">=></span> <span class="o">(</span><span class="n">gitRef</span><span class="o">,</span> <span class="n">runTests</span><span class="o">,</span> <span class="n">env</span><span class="o">)</span> <span class="k">=></span>
<span class="n">println</span><span class="o">(</span><span class="n">s</span><span class="s">"Building app from Git ref $gitRef${if (runTests) "</span> <span class="n">and</span> <span class="n">running</span> <span class="n">tests</span><span class="s">" else ""} and deploying on $env"</span><span class="o">)</span>
<span class="o">}</span>
</code></pre></div></div>
<h2 id="input">Input</h2>
<p>Let’s have a deeper look at the <code class="highlighter-rouge">Input</code>:<br />
<code class="highlighter-rouge">Input</code>s can also be used for other types like <code class="highlighter-rouge">Int</code> or <code class="highlighter-rouge">Double</code>, all you need to do is specifying the type you want to
use: <code class="highlighter-rouge">Input[Int]("Some Int")</code>.</p>
<p>We can also define default values: <code class="highlighter-rouge">Input[Double]("Some Double", default = Option(4.2))</code>.</p>
<p>It is a good practice to type as much as possible and therefore avoid generic types like <code class="highlighter-rouge">String</code>s. Orkestra is able to
handle any case class of one argument:</p>
<div class="language-scala highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">import</span> <span class="nn">tech.orkestra._</span>
<span class="k">import</span> <span class="nn">tech.orkestra.Dsl._</span>
<span class="k">import</span> <span class="nn">tech.orkestra.board._</span>
<span class="k">import</span> <span class="nn">tech.orkestra.job._</span>
<span class="k">import</span> <span class="nn">tech.orkestra.model.JobId</span>
<span class="k">import</span> <span class="nn">tech.orkestra.parameter._</span>
<span class="c1">// We create our better typed Git Ref
</span><span class="k">case</span> <span class="k">class</span> <span class="nc">Ref</span><span class="o">(</span><span class="n">value</span><span class="k">:</span> <span class="kt">String</span><span class="o">)</span> <span class="k">extends</span> <span class="nc">AnyVal</span>
<span class="c1">// Note that we use Ref instead of the generic String
</span><span class="k">lazy</span> <span class="k">val</span> <span class="n">parametersJobBoard</span> <span class="k">=</span> <span class="nc">JobBoard</span><span class="o">[(</span><span class="kt">Ref</span>, <span class="kt">Boolean</span><span class="o">)</span> <span class="k">=></span> <span class="kt">Unit</span><span class="o">](</span><span class="nc">JobId</span><span class="o">(</span><span class="s">"parameters"</span><span class="o">),</span> <span class="s">"Parameters"</span><span class="o">)(</span>
<span class="nc">Input</span><span class="o">[</span><span class="kt">Ref</span><span class="o">](</span><span class="s">"Git ref"</span><span class="o">),</span>
<span class="nc">Checkbox</span><span class="o">(</span><span class="s">"Run tests?"</span><span class="o">)</span>
<span class="o">)</span>
<span class="k">lazy</span> <span class="k">val</span> <span class="n">parametersJob</span> <span class="k">=</span> <span class="nc">Job</span><span class="o">(</span><span class="n">parametersJobBoard</span><span class="o">)</span> <span class="o">{</span> <span class="k">implicit</span> <span class="n">workDir</span> <span class="k">=></span> <span class="o">(</span><span class="n">gitRef</span><span class="o">,</span> <span class="n">runTests</span><span class="o">)</span> <span class="k">=></span>
<span class="n">println</span><span class="o">(</span><span class="n">s</span><span class="s">"Building app from Git ref ${gitRef.value}${if (runTests) "</span> <span class="n">and</span> <span class="n">running</span> <span class="n">tests</span><span class="s">" else ""}"</span><span class="o">)</span>
<span class="o">}</span>
</code></pre></div></div>
<p>Here the text entered by the user will be wrapped into the <code class="highlighter-rouge">Ref</code> case class and given to the <code class="highlighter-rouge">Job</code> function.</p>
<h2 id="checkbox">Checkbox</h2>
<p>By default <code class="highlighter-rouge">Checkbox</code>s are not checked but you can make them checked: <code class="highlighter-rouge">Checkbox("Run tests?", checked = true)</code></p>
</section></div></div></div></div><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script><script src="/highlight/highlight.pack.js"></script><script>hljs.configure({
languages:['scala','java','bash']
});
hljs.initHighlighting();
</script><script>((window.gitter = {}).chat = {}).options = {
room: 'orkestra-tech/Orkestra'};</script><script src="https://sidecar.gitter.im/dist/sidecar.v1.js"></script><script src="/js/main.js"></script></body></html>