Files
confdroid_nagios/Jenkinsfile

246 lines
7.5 KiB
Plaintext
Raw Normal View History

pipeline {
agent {
label 'puppet'
}
stages {
stage('pulling master before adding files') {
steps {
2018-04-12 12:13:28 +02:00
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
sh '''git config user.name "Jenkins Server"
git config user.email jenkins@confdroid.com
git pull origin master
git checkout -b jenkins '''
}
}
}
stage('install required gems') {
steps {
sh 'bundle install'
}
}
stage('puppet-lint tests') {
steps {
2018-04-12 12:13:28 +02:00
sh '''find . -iname *.pp -exec /var/lib/jenkins/bin/puppet-lint \\
--no-class_inherits_from_params_class-check \\
--no-variable_scope-check \\
--no-80chars-check \\
2017-07-25 15:13:38 +01:00
--no-140chars-check \\
--no-arrow_alignment-check \\
--no-autoloader_layout-check \\
--log-format "%{path}:%{line}:%{check}:%{KIND}:%{message}" {} \\;'''
}
}
stage('puppet parser test') {
steps {
sh '''for file in $(find . -iname \'*.pp\'); do
puppet parser validate --color false --render-as s --modulepath=modules $file || exit 1;
done;'''
}
}
stage('Puppet ERB template test') {
steps{
sh '''for file in $(find . -iname \'*.erb\');
do erb -P -x -T "-" $file | ruby -c || exit 1;
done;'''
}
}
stage('compiler warnings') {
steps {
warnings canComputeNew: false, canResolveRelativePaths: false, consoleParsers: [[parserName: 'Puppet-Lint']], defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', unHealthy: ''
}
}
stage('update repo structure') {
steps {
sh '''if [ test -f REPOSTRUCTURE.md ]; then
rm -Rf REPOSTRUCTURE.md
fi
echo "$(tree --dirsfirst --charset=ascii .)" > REPOSTRUCTURE.md'''
}
}
stage('create Puppet documention') {
steps {
sh 'puppet strings'
}
}
stage('create changelog') {
steps{
step([$class: 'GitChangelogRecorder', config: [configFile: 'git-changelog-settings.json', createFileTemplateContent: '''<h1> Git Changelog changelog </h1>
<p>
Changelog of Git Changelog.
</p>
{{#tags}}
<h2> {{name}} </h2>
{{#issues}}
{{#hasIssue}}
{{#hasLink}}
<h2> {{name}} <a href="{{link}}">{{issue}}</a> {{title}} </h2>
{{/hasLink}}
{{^hasLink}}
<h2> {{name}} {{issue}} {{title}} </h2>
{{/hasLink}}
{{/hasIssue}}
{{^hasIssue}}
<h2> {{name}} </h2>
{{/hasIssue}}
{{#commits}}
2018-04-12 12:13:28 +02:00
<a href="https://gitlab.confdroid.com/12WW1160/git-changelog-lib/commit/{{hash}}">{{hash}}</a> {{authorName}} <i>{{commitTime}}</i>
<p>
<h3>{{{messageTitle}}}</h3>
{{#messageBodyItems}}
<li> {{.}}</li>
{{/messageBodyItems}}
</p>
{{/commits}}
{{/issues}}
{{/tags}}
''', createFileTemplateFile: '', createFileUseTemplateContent: true, createFileUseTemplateFile: false, customIssues: [[link: '', name: '', pattern: '', title: ''], [link: '', name: '', pattern: '', title: '']], dateFormat: 'YYYY-MM-dd HH:mm:ss', file: 'CHANGELOG.md', fromReference: '', fromType: 'firstCommit', gitHubApi: '', gitHubApiTokenCredentialsId: '', gitHubIssuePattern: '#([0-9]+)', gitHubToken: '', gitLabApiTokenCredentialsId: '', gitLabProjectName: '', gitLabServer: '', gitLabToken: '', ignoreCommitsIfMessageMatches: '^\\[maven-release-plugin\\].*|^\\[Gradle Release Plugin\\].*|^Merge.*', ignoreCommitsWithoutIssue: false, ignoreTagsIfNameMatches: '', jiraIssuePattern: '\\b[a-zA-Z]([a-zA-Z]+)-([0-9]+)\\b', jiraPassword: '', jiraServer: '', jiraUsername: '', jiraUsernamePasswordCredentialsId: '', mediaWikiPassword: '', mediaWikiTemplateContent: '''__NOTOC__
= Git Changelog changelog =
Changelog of Git Changelog.
{{#tags}}
== {{name}} ==
{{#issues}}
{{#hasIssue}}
{{#hasLink}}
=== {{name}} [{{link}} {{issue}}] {{title}} ===
{{/hasLink}}
{{^hasLink}}
=== {{name}} {{issue}} {{title}} ===
{{/hasLink}}
{{/hasIssue}}
{{^hasIssue}}
=== {{name}} ===
{{/hasIssue}}
{{#commits}}
2018-04-12 12:13:28 +02:00
[https://gitlab.confdroid.com/12WW1160/git-changelog-lib/commit/{{hash}} {{hash}}] {{authorName}} {{commitTime}}
\'\'\'{{{messageTitle}}}\'\'\'
{{#messageBodyItems}}
* {{.}}
{{/messageBodyItems}}
{{/commits}}
{{/issues}}
{{/tags}}
''', mediaWikiTemplateFile: '', mediaWikiTitle: '', mediaWikiUrl: '', mediaWikiUseTemplateContent: false, mediaWikiUseTemplateFile: false, mediaWikiUsername: '', noIssueName: 'No issue', readableTagName: '/([^/]+?)$', showSummary: false, showSummaryTemplateContent: '''<h1> Git Changelog changelog </h1>
<p>
Changelog of Git Changelog.
</p>
{{#tags}}
<h2> {{name}} </h2>
{{#issues}}
{{#hasIssue}}
{{#hasLink}}
<h2> {{name}} <a href="{{link}}">{{issue}}</a> {{title}} </h2>
{{/hasLink}}
{{^hasLink}}
<h2> {{name}} {{issue}} {{title}} </h2>
{{/hasLink}}
{{/hasIssue}}
{{^hasIssue}}
<h2> {{name}} </h2>
{{/hasIssue}}
{{#commits}}
<a href="https://github.com/12WW1160/git-changelog-lib/commit/{{hash}}">{{hash}}</a> {{authorName}} <i>{{commitTime}}</i>
<p>
<h3>{{{messageTitle}}}</h3>
{{#messageBodyItems}}
<li> {{.}}</li>
{{/messageBodyItems}}
</p>
{{/commits}}
{{/issues}}
{{/tags}}
''', showSummaryTemplateFile: '', showSummaryUseTemplateContent: false, showSummaryUseTemplateFile: false, subDirectory: '', timeZone: 'UTC', toReference: '', toType: 'master', untaggedName: 'Unreleased', useConfigFile: false, useFile: true, useGitHub: false, useGitHubApiTokenCredentials: false, useGitLab: false, useGitLabApiTokenCredentials: false, useIgnoreTagsIfNameMatches: false, useJira: false, useJiraUsernamePasswordCredentialsId: false, useMediaWiki: false, useReadableTagName: false, useSubDirectory: false]])
}
}
stage('check for UTF-8 files') {
steps {
sh '''if [ ! -d tests ]; then
mkdir tests
fi
if [ -f tests/UTF_Files ]; then
rm -Rf tests/UTF_Files
fi
echo "$(find . -type f -exec file {} \\;)" > FileList
echo "$(grep -v ASCII FileList | grep -v git)" > tests/UTF_Files'''
}
}
stage('show diff') {
steps {
sh 'git diff'
}
}
2017-07-21 13:15:47 +01:00
stage('recommit changes to repo') {
steps {
2018-04-12 12:13:28 +02:00
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
sh '''git config user.name "Jenkins Server"
git config user.email jenkins@confdroid.com
echo `git add -A && git commit -am "recommit for updates in build $BUILD_NUMBER"`
2018-04-27 19:37:52 +02:00
git push origin HEAD:master'''
}
}
}
stage('update Gitlab') {
steps {
updateGitlabCommitStatus state: 'success'
}
}
}
post {
always {
deleteDir() /* clean up our workspace */
}
success {
echo 'Pipeline finished successfully!'
}
unstable {
echo 'I am unstable :/'
}
failure {
echo 'I failed :('
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'support@confdroid.com', sendToIndividuals: true])
}
changed {
echo 'Things were different before...'
mail bcc: '', body: "Pipeline Job '${JOB_NAME}' has changed, please verify.", cc: '', from: '', replyTo: '', subject: "Pipeline Job '${JOB_NAME}' has changed", to: 'support@confdroid.com'
}
}
}