[JENKINS] Add defaults for GIT config
user.name, user.email filled by default Change-Id: I6abaa5634ab0c6fecbe7785b3267009a2411694b
This commit is contained in:
parent
c0113c32f7
commit
fae7118e2b
@ -20,6 +20,10 @@ Properties:
|
||||
cfplugin:
|
||||
Contract: $.bool()
|
||||
Default: false
|
||||
gitUser:
|
||||
Contract: $.string()
|
||||
gitEmail:
|
||||
Contract: $.string()
|
||||
|
||||
Methods:
|
||||
initialize:
|
||||
@ -64,6 +68,7 @@ Methods:
|
||||
- $.instance.agent.call($template, $resources)
|
||||
|
||||
- $.configureZMQPlugin()
|
||||
- $.configureGitPlugin($.gitUser, $.gitEmail)
|
||||
|
||||
- If: $.instance.assignFloatingIp
|
||||
Then:
|
||||
@ -123,6 +128,33 @@ Methods:
|
||||
- $template: $resources.yaml('ConfigureGearman.template')
|
||||
- $.instance.agent.call($template, $resources)
|
||||
|
||||
configureGitPlugin:
|
||||
Arguments:
|
||||
- gitUser:
|
||||
Contract: $.string()
|
||||
- gitEmail:
|
||||
Contract: $.string()
|
||||
Body:
|
||||
# Set defaults if not provided.
|
||||
- If: $gitUser in ['', null]
|
||||
Then:
|
||||
- $gitUsername: 'user'
|
||||
Else:
|
||||
- $gitUsername: $gitUser
|
||||
|
||||
- If: $gitEmail in ['', null]
|
||||
Then:
|
||||
- $gitUserEmail: 'user@mirantis.test'
|
||||
Else:
|
||||
- $gitUserEmail: $gitEmail
|
||||
|
||||
- $.instance.setHieraValue('git_user', $gitUsername)
|
||||
- $.instance.setHieraValue('git_user_email', $gitUserEmail)
|
||||
- $resources: new(sys:Resources)
|
||||
- $._environment.reporter.report($this, 'Configure Jenkins Git plugin...')
|
||||
- $template: $resources.yaml('ConfigureGit.template')
|
||||
- $.instance.agent.call($template, $resources)
|
||||
|
||||
destroy:
|
||||
Body:
|
||||
- $.reportDestroyed()
|
||||
|
19
murano-apps/Jenkins/package/Resources/ConfigureGit.template
Normal file
19
murano-apps/Jenkins/package/Resources/ConfigureGit.template
Normal file
@ -0,0 +1,19 @@
|
||||
FormatVersion: 2.1.0
|
||||
Version: 1.0.0
|
||||
Name: Configure Git
|
||||
|
||||
Body: |
|
||||
return configureGit().stdout
|
||||
|
||||
Scripts:
|
||||
configureGit:
|
||||
Type: Application
|
||||
Version: 1.0.0
|
||||
EntryPoint: configure_git.sh
|
||||
Files:
|
||||
- configure_git/templates/hudson.plugins.git.GitSCM.xml.erb
|
||||
- configure_git/manifests/init.pp
|
||||
- configure_git.pp
|
||||
Options:
|
||||
captureStdout: true
|
||||
captureStderr: true
|
@ -0,0 +1,6 @@
|
||||
node default {
|
||||
class { 'configure_git':
|
||||
git_user => hiera('git_user'),
|
||||
git_user_email => hiera('git_user_email')
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
# No error if already exists.
|
||||
mkdir -p /etc/puppet/modules/configure_git
|
||||
mkdir -p /etc/puppet/modules/configure_git/manifests/
|
||||
mkdir -p /etc/puppet/modules/configure_git/templates/
|
||||
|
||||
cp configure_git/manifests/init.pp /etc/puppet/modules/configure_git/manifests/
|
||||
cp configure_git/templates/hudson.plugins.git.GitSCM.xml.erb /etc/puppet/modules/configure_git/templates/
|
||||
|
||||
puppet apply configure_git.pp
|
@ -0,0 +1,17 @@
|
||||
class configure_git (
|
||||
$git_user = undef,
|
||||
$git_user_email = undef
|
||||
) {
|
||||
service { 'jenkins':
|
||||
ensure => running,
|
||||
enable => true,
|
||||
}
|
||||
file { '/var/lib/jenkins/hudson.plugins.git.GitSCM.xml':
|
||||
notify => Service['jenkins'],
|
||||
ensure => present,
|
||||
owner => 'jenkins',
|
||||
group => 'jenkins',
|
||||
mode => '0644',
|
||||
content => template('configure_git/hudson.plugins.git.GitSCM.xml.erb'),
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<hudson.plugins.git.GitSCM_-DescriptorImpl plugin="git@1.1.23">
|
||||
<generation>1</generation>
|
||||
<globalConfigName><%= git_user %></globalConfigName>
|
||||
<globalConfigEmail><%= git_user_email %></globalConfigEmail>
|
||||
<createAccountBasedOnEmail>false</createAccountBasedOnEmail>
|
||||
</hudson.plugins.git.GitSCM_-DescriptorImpl>
|
@ -6,6 +6,8 @@ Application:
|
||||
name: $.appConfiguration.name
|
||||
ldap: $.appConfiguration.OpenLDAP
|
||||
cfplugin: $.appConfiguration.cfplugin
|
||||
gitUser: $.appConfiguration.gitUser
|
||||
gitEmail: $.appConfiguration.gitEmail
|
||||
instance:
|
||||
?:
|
||||
type: io.murano.opaas.puppet.PuppetInstance
|
||||
@ -45,6 +47,20 @@ Forms:
|
||||
required: false
|
||||
description: >-
|
||||
Specify OpenLDAP domain for authentication
|
||||
- name: gitUser
|
||||
type: string
|
||||
label: Git username
|
||||
required: false
|
||||
regexpValidator: '^[-_\w]+$'
|
||||
description: >-
|
||||
Enter a desired name for git user
|
||||
- name: gitEmail
|
||||
type: string
|
||||
label: Git user email
|
||||
required: false
|
||||
regexpValidator: '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$'
|
||||
description: >-
|
||||
Enter a desired email for git user
|
||||
- instanceConfiguration:
|
||||
fields:
|
||||
- name: title
|
||||
|
Loading…
x
Reference in New Issue
Block a user