Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Scriptler example in README.md #38

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 71 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,77 @@ To make your Scriptler scripts reusable across multiple projects you
should parameterize them and assign script parameters using build
parameters.

TODO: Provide an example
#### Example

Environments.groovy in Scriptler
``` syntaxhighlighter-pre
return ["Select:selected", "DEV", "TEST", "STAGE", "PROD"]
```

HostsInEnv.groovy in Scriptler
``` syntaxhighlighter-pre
// Static content examples. These lists can be generated dynamically as an alternative.
List devList = ["Select:selected", "dev1", "dev2"]
List testList = ["Select:selected", "test1", "test2", "test3"]
List stageList = ["Select:selected", "stage1"]
List prodList = ["Select:selected", "prod1", "prod2", "prod3", "prod4"]

List default_item = ["None"]

if (Environment.equals('DEV')) {
return devList
} else if (Environment.equals('TEST')) {
return testList
} else if (Environment.equals('STAGE')) {
return stageList
} else if (Environment.equals('PROD')) {
return prodList
} else {
return default_item
}
```

Pipeline in Jenkinsfile
``` syntaxhighlighter-pre
properties([
parameters([
[
$class: 'ChoiceParameter',
choiceType: 'PT_SINGLE_SELECT',
name: 'Environment',
script: [
$class: 'ScriptlerScript',
scriptlerScriptId:'Environments.groovy'
]
],
[
$class: 'CascadeChoiceParameter',
choiceType: 'PT_SINGLE_SELECT',
name: 'Host',
referencedParameters: 'Environment',
script: [
$class: 'ScriptlerScript',
scriptlerScriptId:'HostsInEnv.groovy',
parameters: [
[name:'Environment', value: '$Environment']
]
]
]
])
])

pipeline {
agent any
stages {
stage('Build') {
steps {
echo "${params.Environment}"
echo "${params.Host}"
}
}
}
}
```

### Filter Supports Regular Expressions

Expand Down