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

Add MacOSX support #15

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ac5bf9d
Update install.pp
jordigg Feb 16, 2016
69b42c5
Update install.pp
jordigg Feb 16, 2016
6903680
Update install.pp
jordigg Feb 16, 2016
bf152e7
Update install.pp
jordigg Feb 16, 2016
109a513
Update install.pp
jordigg Feb 16, 2016
2afefac
Update install.pp
jordigg Feb 16, 2016
a647009
Update install.pp
jordigg Feb 16, 2016
5d03a76
Update service.pp
jordigg Feb 16, 2016
84043d2
Update service.pp
jordigg Feb 16, 2016
9d43c33
Update build-agent-service.erb
jordigg Feb 16, 2016
acd8361
Update service.pp
jordigg Feb 16, 2016
f8159f1
Update build-agent-service.erb
jordigg Feb 16, 2016
f84b93b
Update build-agent-service.erb
jordigg Feb 16, 2016
d1f58b7
Update build-agent-service.erb
jordigg Feb 16, 2016
16fe0b1
Make teamcity work, temp and system paths configurable
Feb 22, 2016
4d8c096
Make teamcity work, temp and system paths configurable
Feb 22, 2016
8ceef6b
Make teamcity work, temp and system paths configurable
Feb 22, 2016
295bff1
Make teamcity work, temp and system paths configurable
Feb 22, 2016
19ae113
Make teamcity work, temp and system paths configurable
Feb 22, 2016
ffb9c9e
Make teamcity work, temp and system paths configurable
Feb 22, 2016
dbf8214
Adding mac support
Mar 3, 2016
785ea83
Adding mac support
Mar 7, 2016
dcb2e18
Adding mac support
Mar 7, 2016
66dbc5a
Adding mac support
Mar 7, 2016
3e16fb1
Adding mac support
Mar 7, 2016
a4f957a
Adding mac support
Mar 7, 2016
5dfb530
Adding mac support
Mar 7, 2016
353f270
Adding mac support
Mar 7, 2016
4a63d0a
Adding mac support
Mar 7, 2016
4260c08
Adding mac support
Mar 7, 2016
65b70e5
Adding mac support
Mar 7, 2016
5116f3a
Adding mac support
Mar 7, 2016
e3960a0
Adding mac support
Mar 7, 2016
b294edf
Adding mac support
Mar 7, 2016
16c508c
Adding mac support
Mar 7, 2016
636a7f6
Adding mac support
Mar 7, 2016
9469673
Adding mac support
Mar 7, 2016
23d64d4
Adding mac support
Mar 7, 2016
3f00727
Adding mac support
Mar 7, 2016
228a674
Adding mac support
Mar 10, 2016
30215a5
Adding mac support
Mar 11, 2016
4167d56
Adding mac support
Mar 11, 2016
9d81448
Adding mac support
Mar 11, 2016
3fb43f3
Adding mac support
Mar 11, 2016
5fcebe6
Adding mac support
Mar 11, 2016
a94c6a8
Fixing permissions on MacOSX launcher folder
Apr 5, 2016
ed37266
Fixing access not yet evaluated on params
Apr 25, 2016
d1bec7e
Merge pull request #1 from improbable-io/adding-mac-support
jordigg May 25, 2016
bf42d28
Added Support for Ubuntu 16.04 LTS to metadata.json
May 25, 2016
3ecf4d9
Make Install Idempotent and set executable once.
gavinelder Oct 21, 2018
ab356af
Update MetaData to support 18.04
gavinelder Oct 21, 2018
a883495
Merge pull request #2 from GavinElder/master
gavinelder Oct 22, 2018
72bf366
Update install.pp
Nov 1, 2018
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
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,19 @@ Defaults to `${server_url}/update/${archive_name}`.

####`agent_dir`
Installation path, where build agent will reside.
Defaults to `/opt/build-agent`.
Defaults to `/opt/build-agent` on Linux, `/Applications` on MacOSX and `C:/buildAgent` on Windows.

####`work_dir`
Work path used by teamcity.
Defaults to `../work`.

####`temp_dir`
Temp path used by teamcity.
Defaults to `../temp`.

####`system_dir`
System path used by teamcity.
Defaults to `../system`.

####`service_ensure`
Required service status. Defaults to `running`.
Expand All @@ -96,7 +108,7 @@ standalone mode the shortcut is created in Startup forlder of specified
user. This mode is required in some cases to overcome service's
shortcomings (it could interact with desktop, so, it could not for
example create direct3d device).
Default on Windows is `service` and on Linux `init` or `systemd` depending
Default on Windows and MacOSX is `service` and on Linux `init` or `systemd` depending
on your OS version.

####`teamcity_agent_mem_opts`
Expand All @@ -106,4 +118,4 @@ String for configuring additional java parameters for build agent.
Hash of custom properties, that will be applied to conf/buildAgent.properties

####`launcher_wrapper_conf`
Hash of custom properties, that will be applied to launcher/conf/wrapper.conf
Hash of custom properties, that will be applied to launcher/conf/wrapper.conf
34 changes: 26 additions & 8 deletions manifests/account.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,32 @@
default => $agent_user_home,
}

user { $agent_user:
ensure => 'present',
home => $_agent_user_home_real,
managehome => $manage_agent_user_home,
gid => $agent_group,
shell => '/bin/sh',
require => $group_require,
if $::kernel == 'darwin' {
if $manage_agent_user_home == true {
file { $_agent_user_home_real:
ensure => directory,
before => User[$agent_user],
}
}
user { $agent_user:
ensure => 'present',
home => $_agent_user_home_real,
managehome => false,
gid => $agent_group,
shell => '/bin/bash',
require => $group_require,
}
} else {
user { $agent_user:
ensure => 'present',
home => $_agent_user_home_real,
managehome => $manage_agent_user_home,
gid => $agent_group,
shell => '/bin/sh',
require => $group_require,
}
}

}
}
}
}
21 changes: 19 additions & 2 deletions manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@
# Service type
# On windows defaults to `service`, on Linux defaults to `init`.
#
# [*work_dir*]
# Path to the work directory.
# Defaults to `../work`.
#
# [*temp_dir*]
# Path to the temp directory.
# Defaults to `../temp`.
#
# [*system_dir*]
# Path to the system directory.
# Defaults to `../system`.exi
#
# [*teamcity_agent_mem_opts*]
# String for configuring additional java parameters for build agent
#
Expand All @@ -72,7 +84,7 @@
# === Examples
#
# === Authors
# grundic
# grundic jordigg
#
# === Copyright
# Copyright 2012-2014 Grigory Chernyshev
Expand All @@ -94,6 +106,11 @@
$service_ensure = $teamcity::params::service_ensure,
$service_enable = $teamcity::params::service_enable,
$service_run_type = $teamcity::params::service_run_type,

$work_dir = $teamcity::params::agent::work_dir,
$temp_dir = $teamcity::params::agent::temp_dir,
$system_dir = $teamcity::params::agent::system_dir,

$teamcity_agent_mem_opts = $teamcity::params::teamcity_agent_mem_opts,
$custom_properties = $teamcity::params::custom_properties,
$launcher_wrapper_conf = $teamcity::params::launcher_wrapper_conf,
Expand All @@ -107,4 +124,4 @@
class {'::teamcity::agent::install':} ->
class {'::teamcity::agent::config':} ~>
class {'::teamcity::agent::service':}
}
}
19 changes: 17 additions & 2 deletions manifests/agent/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@
$custom_properties = $teamcity::agent::custom_properties
$launcher_wrapper_conf = $teamcity::agent::launcher_wrapper_conf
$teamcity_agent_mem_opts = $teamcity::agent::teamcity_agent_mem_opts
$work_dir = $teamcity::agent::work_dir
$temp_dir = $teamcity::agent::temp_dir
$system_dir = $teamcity::agent::system_dir

$required_properties = {
'serverUrl' => $server_url,
'name' => $agent_name
'name' => $agent_name,
'workDir' => $work_dir,
'tempDir' => $temp_dir,
'systemDir' => $system_dir,
}

# configure buildAgent.properties
Expand All @@ -42,6 +48,15 @@
mergemode => clobber,
}
}
elsif $::kernel == 'darwin' {
file { '/Library/LaunchDaemons/jetbrains.teamcity.BuildAgent.plist':
ensure => 'present',
owner => 'root',
group => 'wheel',
mode => '0644',
content => template("${module_name}/jetbrains.teamcity.BuildAgent.plist"),
}
}
else {
case $service_run_type {
'init': {
Expand Down Expand Up @@ -74,4 +89,4 @@
content => template("${module_name}/teamcity-profile.erb"),
}
}
}
}
52 changes: 40 additions & 12 deletions manifests/agent/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,45 @@
}
}
else {
wget::fetch { 'teamcity-buildagent':
source => $download_url,
destination => "${::temp_dir}/${archive_name}",
flags => ['--no-proxy'],
timeout => 0,
}

exec { 'extract-agent-archive':
command => "unzip ${::temp_dir}/${archive_name} -d ${agent_dir}",
creates => "${agent_dir}/conf",
logoutput => 'on_failure',
require => Wget::Fetch['teamcity-buildagent']
if $::kernel == 'darwin' {
exec { 'download-agent-archive':
command => "curl -L -o ${::temp_dir}/${archive_name} ${download_url}",
creates => "${::temp_dir}/${archive_name}",
notify => Exec['extract-agent-archive']
}
exec { 'extract-agent-archive':
command => "unzip ${::temp_dir}/${archive_name} -d ${agent_dir}",
creates => "${agent_dir}/conf",
logoutput => 'on_failure',
require => Exec['download-agent-archive'],
notify => Exec['fix-launcher-permissions']
}
exec { 'fix-launcher-permissions':
command => "chmod +x ${agent_dir}/launcher/bin/*",
require => Exec['extract-agent-archive'],
refreshonly => true
}
file { "${agent_dir}/logs" :
ensure => directory,
owner => $agent_user,
group => $agent_group,
subscribe => Exec['extract-agent-archive'],
require => Exec['extract-agent-archive'],
recurse => true,
}
}else {
wget::fetch { 'teamcity-buildagent':
source => $download_url,
destination => "${::temp_dir}/${archive_name}",
flags => ['--no-proxy'],
timeout => 0,
}
exec { 'extract-agent-archive':
command => "unzip ${::temp_dir}/${archive_name} -d ${agent_dir}",
creates => "${agent_dir}/conf",
logoutput => 'on_failure',
require => Wget::Fetch['teamcity-buildagent']
}
}

file {'agent-config':
Expand All @@ -75,5 +102,6 @@
mode => '0755',
require => Exec['extract-agent-archive']
}

}
}
17 changes: 16 additions & 1 deletion manifests/agent/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@
fail('$service_run_type must be either service or standalone')
}
}
elsif $::kernel == 'darwin' {
exec { 'first-run':
command => "sh ${agent_dir}/bin/mac.launchd.sh load",
user => $agent_user,
refreshonly => true,
before => Service['jetbrains.teamcity.BuildAgent'],
}
service { 'jetbrains.teamcity.BuildAgent':
enable => $service_enable,
ensure => $service_ensure,
provider => $service_run_type,
require => File["/Library/LaunchDaemons/jetbrains.teamcity.BuildAgent.plist"],
subscribe => File["/Library/LaunchDaemons/jetbrains.teamcity.BuildAgent.plist"],
}
}
else {
if $service_run_type == 'systemd' {
service { 'build-agent':
Expand Down Expand Up @@ -76,4 +91,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# [Remember: No empty lines between comments and class definition]
class teamcity {

}
}
15 changes: 13 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,37 @@
$agent_user = 'teamcity'
$agent_user_home = undef
$manage_agent_user_home = false
$agent_group = 'teamcity'
$manage_user = false
$manage_group = false

$server_url = 'http://builder'
$archive_name = 'buildAgent.zip'
$download_url = "${server_url}/update/${archive_name}"

$work_dir = "../work"
$temp_dir = "../temp"
$system_dir = "../system"

if $::kernel == 'windows' {
$agent_dir = 'C:/buildAgent'
}
elsif $::kernel == 'darwin' {
$agent_dir = '/Applications'
$agent_group = 'staff'
}
else {
$agent_dir = '/opt/build-agent'
$agent_group = 'teamcity'
}

$service_ensure = 'running'
$service_enable = true
if $::kernel == 'windows' {
$service_run_type = 'service'
}
elsif $::kernel == 'darwin' {
$service_run_type = 'launchd'
}
else {
if ($::operatingsystem == "Debian" and versioncmp($::operatingsystemmajrelease, '7') >= 0) or ($::operatingsystem == "Ubuntu" and versioncmp($::operatingsystemmajrelease, '15.04') >= 0) {
$service_run_type = 'systemd'
Expand All @@ -34,4 +45,4 @@
$teamcity_agent_mem_opts = '-Xms512m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8'
$custom_properties = {}
$launcher_wrapper_conf = {}
}
}
11 changes: 9 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,23 @@
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
"7",
"8"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04",
"14.04"
"14.04",
"15.10",
"16.04",
"18.04"
]
},
{
"operatingsystem": "Darwin"
},
{
"operatingsystem": "Windows",
"operatingsystemrelease": [
Expand Down
4 changes: 2 additions & 2 deletions templates/build-agent-service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Description=TeamCity Build Agent
After=network.target

[Service]
Type=forking
Type=simple
User=<%= @agent_user %>
PIDFile=<%= @agent_dir %>/logs/buildAgent.pid
ExecStart=<%= @agent_dir %>/bin/agent.sh start
ExecStart=<%= @agent_dir %>/bin/agent.sh run
ExecStop=<%= @agent_dir %>/bin/agent.sh stop

[Install]
Expand Down
32 changes: 32 additions & 0 deletions templates/jetbrains.teamcity.BuildAgent.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UserName</key>
<string><%= @agent_user %></string>
<key>Debug</key>
<false/>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>jetbrains.teamcity.BuildAgent</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string><%= @agent_dir %>/launcher/bin/TeamCityAgentService-macosx-universal-32</string>
<string>-c</string>
<string>../conf/wrapper.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>SessionCreate</key>
<true/>
<key>StandardErrorPath</key>
<string>logs/launchd.err.log</string>
<key>StandardOutPath</key>
<string>logs/launchd.out.log</string>
<key>WorkingDirectory</key>
<string><%= @agent_dir %></string>
</dict>
</plist>