-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate seed job Groovy script from XML
This makes the script easier to read and modify. The conversion of special characters is done by a custom Jinja2 filter. Add '*.pyc' to '.gitignore'.
- Loading branch information
Olav Philipp Henschel
committed
Oct 16, 2017
1 parent
39e5397
commit 450547d
Showing
5 changed files
with
26 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.pyc | ||
*.retry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
def escape_to_xml(string): | ||
char_to_escaped_string = [ | ||
('"', '"'), | ||
("'", '''), | ||
('<', '<'), | ||
('>', '>') | ||
] | ||
for char, escaped in char_to_escaped_string: | ||
string = string.replace(char, escaped) | ||
return string | ||
|
||
|
||
class FilterModule(object): | ||
def filters(self): | ||
return {'escape_to_xml': escape_to_xml} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
--- | ||
seed_job_name: seed_job | ||
seed_job_script_path: "{{seed_job_name}}.groovy" | ||
seed_job_script: "{{ lookup('file', seed_job_script_path) }}" | ||
seed_job_script_xml: "{{ seed_job_script | escape_to_xml }}" | ||
seed_job_template: "{{seed_job_name}}_config.xml.j2" | ||
seed_job_target_dir: "{{jenkins_home_dir}}/jobs/{{seed_job_name}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node ('master') { | ||
git credentialsId: 'github-user-pass-credentials', | ||
url: REPOSITORY_URL, | ||
branch: REPOSITORY_COMMIT | ||
jobDsl targets: JOB_DESCRIPTORS_FILES | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,13 +58,7 @@ | |
</org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty> | ||
</properties> | ||
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="[email protected]"> | ||
<script> | ||
node ('master') { | ||
git credentialsId: 'github-user-pass-credentials', | ||
url: REPOSITORY_URL, | ||
branch: REPOSITORY_COMMIT | ||
jobDsl targets: JOB_DESCRIPTORS_FILES | ||
}</script> | ||
<script>{{seed_job_script_xml}}</script> | ||
<sandbox>true</sandbox> | ||
</definition> | ||
<triggers/> | ||
|