add Jenkinsfile

This commit is contained in:
12WW1160
2020-12-02 18:39:56 +01:00
parent 633a321f03
commit 4a79d9cbe4
2 changed files with 26 additions and 154 deletions

View File

@@ -1,7 +1,7 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
puppetversion = ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'] : ['<= 5.5.6']
gem 'metadata-json-lint'
gem 'metadata-json-lint', '~> 2.4'
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 1.0.0'
gem 'puppet-lint'
@@ -9,11 +9,12 @@ gem 'facter'
gem 'rspec-puppet'
gem 'yard'
gem 'puppet-strings', '< 2.0.0'
gem 'rake', '~> 12.3', '>= 12.3.3'
gem 'semantic_puppet'
gem 'rgen'
gem 'public_suffix', '<= 2.0.5'
gem 'parallel', '<= 1.13.0'
gem 'rake', '~> 12.3', '>= 12.3.3'
gem 'puppet-syntax', '~> 2.6', '>= 2.6.1'
# rspec must be v2 for ruby 1.8.7
if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9'

175
Jenkinsfile vendored
View File

@@ -3,9 +3,24 @@ pipeline {
label 'puppet'
}
post {
always {
deleteDir() /* clean up our workspace */
}
success {
updateGitlabCommitStatus state: 'success'
echo 'Pipeline finished successfully!'
}
failure {
updateGitlabCommitStatus state: 'failed'
echo 'I failed :('
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'support@confdroid.com', sendToIndividuals: true])
}
}
stages {
stage('pulling master before adding files') {
stage('pulling master') {
steps {
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
sh '''git config user.name "Jenkins Server"
@@ -16,13 +31,13 @@ pipeline {
}
}
stage('install required gems') {
stage('install gems') {
steps {
sh 'bundle install'
}
}
stage('puppet-lint tests') {
stage('puppet-lint') {
steps {
sh '''find . -iname *.pp -exec /var/lib/jenkins/bin/puppet-lint \\
--no-class_inherits_from_params_class-check \\
@@ -35,7 +50,7 @@ pipeline {
}
}
stage('puppet parser test') {
stage('puppet parser') {
steps {
sh '''for file in $(find . -iname \'*.pp\'); do
/opt/puppetlabs/bin/puppet parser validate --color false --render-as s --modulepath=modules $file || exit 1;
@@ -43,7 +58,7 @@ pipeline {
}
}
stage('Puppet ERB template test') {
stage('check templates') {
steps{
sh '''for file in $(find . -iname \'*.erb\');
do erb -P -x -T "-" $file | ruby -c || exit 1;
@@ -53,7 +68,7 @@ pipeline {
stage('compiler warnings') {
steps {
warnings canComputeNew: false, canResolveRelativePaths: false, consoleParsers: [[parserName: 'Puppet-Lint']], defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', unHealthy: ''
scanForIssues tool: puppetLint()
}
}
@@ -70,125 +85,7 @@ pipeline {
}
}
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}}
<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}}
[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://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}}
''', 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('show diff') {
steps {
sh 'git diff'
}
}
stage('recommit changes to repo') {
stage('update repo') {
steps {
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
sh '''git config user.name "Jenkins Server"
@@ -198,31 +95,5 @@ Changelog of Git Changelog.
}
}
}
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'
}
}
}
}