forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request NixOS#4 from briangebala/teamcity
TeamCity package and services.
- Loading branch information
Showing
7 changed files
with
465 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,125 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
cfg = config.services.teamcity-agent; | ||
stateDir = "/opt/teamcity/agent"; | ||
in | ||
{ | ||
options = { | ||
services.teamcity-agent = { | ||
enable = mkOption { | ||
default = false; | ||
description = "Whether to enable the TeamCity agent."; | ||
type = types.bool; | ||
}; | ||
|
||
heapSize = mkOption { | ||
default = "384m"; | ||
description = "Max heap size for the TeamCity Java process."; | ||
type = types.str; | ||
}; | ||
|
||
gitPublicKey = mkOption { | ||
description = "Contents of the public SSH key file for checking out from GitHub."; | ||
type = types.str; | ||
}; | ||
|
||
gitPrivateKey = mkOption { | ||
description = "Contents of the private SSH key file for checking out from GitHub."; | ||
type = types.str; | ||
}; | ||
|
||
sonatypeUser = mkOption { | ||
description = "Sonatype user needed to build s2-online"; | ||
type = types.str; | ||
}; | ||
|
||
sonatypePassword = mkOption { | ||
description = "Sonatype password needed to build s2-online"; | ||
type = types.str; | ||
}; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
systemd.services.teamcity-agent = { | ||
description = "TeamCity agent"; | ||
|
||
requires = [ "teamcity.service" ]; | ||
|
||
after = [ "network-interfaces.target" ]; | ||
wantedBy = [ "multi-user.target" ]; | ||
|
||
path = [ pkgs.bash pkgs.procps pkgs.jre pkgs.git pkgs.pkgconfig pkgs.openssh ]; | ||
|
||
preStart = | ||
let | ||
sbtCreds = builtins.toFile "allenai.sbt" '' | ||
credentials += Credentials("Sonatype Nexus Repository Manager", | ||
"utility.allenai.org", | ||
"${cfg.sonatypeUser}", | ||
"${cfg.sonatypePassword}") | ||
''; | ||
sshConfig = builtins.toFile "config" ''Host github.com | ||
IdentityFile ${stateDir}/.ssh/git-dev | ||
''; | ||
in | ||
'' | ||
if [ ! -d ${stateDir}/.ssh ] ; then | ||
mkdir -p ${stateDir}/.ssh | ||
cp ${sshConfig} ${stateDir}/.ssh/config; | ||
echo "${cfg.gitPrivateKey}" > ${stateDir}/.ssh/git-dev | ||
echo "${cfg.gitPublicKey}" > ${stateDir}/.ssh/git-dev.pub | ||
mkdir -p ${stateDir}/sbt | ||
cp ${sbtCreds} ${stateDir}/sbt/allenai.sbt; | ||
mkdir -p ${stateDir}/bin | ||
ln -s /bin/sh ${stateDir}/bin/sh | ||
fi | ||
cp ${pkgs.teamcity}/buildAgent/bin/*.sh ${stateDir}/bin | ||
mkdir -p ${stateDir}/conf | ||
cp ${pkgs.teamcity}/buildAgent/conf/buildAgent.properties ${stateDir}/conf | ||
mkdir -p ${stateDir}/lib | ||
cp ${pkgs.teamcity}/buildAgent/lib/*.jar ${stateDir}/lib | ||
mkdir -p ${stateDir}/logs | ||
chown -R teamcity-agent:teamcity-agent ${stateDir} | ||
chmod -R ug+rw ${stateDir} | ||
chmod -R a+rX /opt/teamcity | ||
chmod -R 600 ${stateDir}/.ssh | ||
''; | ||
|
||
serviceConfig = { | ||
User = "teamcity-agent"; | ||
WorkingDirectory = stateDir; | ||
PermissionsStartOnly = true; | ||
ExecStart = '' | ||
${pkgs.jre}/bin/java \ | ||
-ea \ | ||
-cp ${stateDir}/lib/launcher.jar \ | ||
jetbrains.buildServer.agent.Launcher \ | ||
-ea \ | ||
-Xmx${cfg.heapSize} \ | ||
-Dteamcity_logs=${stateDir}/logs/ \ | ||
-Dlog4j.configuration=file:${pkgs.teamcity}/buildAgent/conf/teamcity-agent-log4j.xml \ | ||
jetbrains.buildServer.agent.AgentMain \ | ||
-file ${stateDir}/conf/buildAgent.properties | ||
''; | ||
}; | ||
}; | ||
|
||
environment.systemPackages = [ pkgs.teamcity ]; | ||
|
||
users.extraUsers.teamcity-agent = { | ||
group = "teamcity-agent"; | ||
home = stateDir; | ||
createHome = true; | ||
}; | ||
|
||
users.extraGroups.teamcity-agent = {}; | ||
}; | ||
} |
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,106 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
cfg = config.services.teamcity; | ||
stateDir = "/opt/teamcity/server"; | ||
in | ||
|
||
{ | ||
options = { | ||
services.teamcity = { | ||
enable = mkOption { | ||
default = false; | ||
description = "Whether to enable TeamCity."; | ||
type = types.bool; | ||
}; | ||
|
||
heapSize = mkOption { | ||
default = "512m"; | ||
description = "Max heap size for the TeamCity Java process."; | ||
type = types.str; | ||
}; | ||
|
||
gitPublicKey = mkOption { | ||
description = "Contents of the public SSH key file for checking out from GitHub."; | ||
type = types.str; | ||
}; | ||
|
||
gitPrivateKey = mkOption { | ||
description = "Contents of the private SSH key file for checking out from GitHub."; | ||
type = types.str; | ||
}; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
|
||
systemd.services.teamcity = { | ||
description = "TeamCity"; | ||
|
||
after = [ "network-interfaces.target" ]; | ||
wantedBy = [ "multi-user.target" ]; | ||
|
||
preStart = | ||
let | ||
sshConfig = builtins.toFile "config" ''Host github.com | ||
IdentityFile ${stateDir}/.ssh/git-dev | ||
''; | ||
in | ||
'' | ||
mkdir -p ${stateDir}/.ssh | ||
cp ${sshConfig} ${stateDir}/.ssh/config; | ||
echo "${cfg.gitPrivateKey}" > ${stateDir}/.ssh/git-dev | ||
echo "${cfg.gitPublicKey}" > ${stateDir}/.ssh/git-dev.pub | ||
mkdir -p ${stateDir}/work | ||
cp -r ${pkgs.teamcity}/webapps ${stateDir} | ||
chown -R teamcity:teamcity ${stateDir} | ||
chmod -R u+rw ${stateDir} | ||
chmod -R a+rX /opt | ||
''; | ||
|
||
serviceConfig = { | ||
User = "teamcity"; | ||
WorkingDirectory = stateDir; | ||
PermissionsStartOnly = true; | ||
ExecStart = '' | ||
${pkgs.jre}/bin/java \ | ||
-Djava.util.logging.config.file=${pkgs.teamcity}/conf/logging.properties \ | ||
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \ | ||
-server \ | ||
-Xmx${cfg.heapSize} \ | ||
-XX:MaxPermSize=270m \ | ||
-Dlog4j.configuration=file:${pkgs.teamcity}/conf/teamcity-server-log4j.xml \ | ||
-Dteamcity_logs=${stateDir} \ | ||
-Djsse.enableSNIExtension=false \ | ||
-Djava.awt.headless=true \ | ||
-Djava.endorsed.dirs=${pkgs.teamcity}/endorsed \ | ||
-classpath ${pkgs.teamcity}/bin/bootstrap.jar:${pkgs.teamcity}/bin/tomcat-juli.jar \ | ||
-Dcatalina.home=${pkgs.teamcity} \ | ||
-Djava.io.tmpdir=${stateDir} \ | ||
org.apache.catalina.startup.Bootstrap start | ||
''; | ||
}; | ||
}; | ||
|
||
environment.systemPackages = [ pkgs.teamcity ]; | ||
|
||
users.extraUsers.teamcity = { | ||
group = "teamcity"; | ||
home = stateDir; | ||
createHome = true; | ||
}; | ||
|
||
users.extraGroups.teamcity = {}; | ||
|
||
# users.extraUsers = lib.singleton { | ||
# name = "teamcity"; | ||
# description = "teamcity"; | ||
# home = stateDir; | ||
# createHome = true; | ||
# extraGroups = [ "users" ]; | ||
# }; | ||
}; | ||
} |
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,63 @@ | ||
## TeamCity build agent configuration file | ||
|
||
###################################### | ||
# Required Agent Properties # | ||
###################################### | ||
|
||
## The address of the TeamCity server. The same as is used to open TeamCity web interface in the browser. | ||
## The address may contain "http://" or "https://" prefix. If omitted, the http protocol is used. | ||
## Example 1: serverUrl=buildserver.mydomain.com | ||
## Example 2: serverUrl=https://buildserver.mydomain.com:8111 | ||
serverUrl=http://localhost:8111/ | ||
|
||
## The unique name of the agent used to identify this agent on the TeamCity server | ||
## Use blank name to let server generate it. | ||
## By default, this name would be created from the build agent's host name | ||
name= | ||
|
||
## Container directory to create default checkout directories for the build configurations. | ||
workDir=/opt/teamcity/agent/work | ||
|
||
## Container directory for the temporary directories. | ||
## Please note that the directory may be cleaned between the builds. | ||
tempDir=/opt/teamcity/agent/temp | ||
|
||
## Container directory for agent system files | ||
systemDir=/opt/teamcity/agent/system | ||
|
||
|
||
###################################### | ||
# Optional Agent Properties # | ||
###################################### | ||
|
||
## The IP address which will be used by TeamCity server to connect to the build agent. | ||
## If not specified, it is detected by build agent automatically, | ||
## but if the machine has several network interfaces, automatic detection may fail. | ||
#ownAddress=<own IP address or server-accessible domain name> | ||
|
||
## Optional | ||
## A port that TeamCity server will use to connect to the agent. | ||
## Please make sure that incoming connections for this port | ||
## are allowed on the agent computer (e.g. not blocked by a firewall) | ||
ownPort=9090 | ||
|
||
## A token which is used to identify this agent on the TeamCity server. | ||
## It is automatically generated and saved on the first agent connection to the server. | ||
authorizationToken= | ||
|
||
|
||
###################################### | ||
# Default Build Properties # | ||
###################################### | ||
## All properties starting with "system.name" will be passed to the build script as "name" | ||
## All properties starting with "env.name" will be set as environment variable "name" for the build process | ||
## Note that value should be properly escaped. (use "\\" to represent single backslash ("\")) | ||
## More on file structure: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#load(java.io.InputStream) | ||
|
||
# Build Script Properties | ||
|
||
#system.exampleProperty=example Value | ||
|
||
# Environment Variables | ||
|
||
#env.exampleEnvVar=example Env Value |
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,65 @@ | ||
## TeamCity build agent configuration file | ||
|
||
###################################### | ||
# Required Agent Properties # | ||
###################################### | ||
|
||
## The address of the TeamCity server. The same as is used to open TeamCity web interface in the browser. | ||
## The address may contain "http://" or "https://" prefix. If omitted, the http protocol is used. | ||
## Example 1: serverUrl=buildserver.mydomain.com | ||
## Example 2: serverUrl=https://buildserver.mydomain.com:8111 | ||
serverUrl=http://localhost:8111/ | ||
|
||
## The unique name of the agent used to identify this agent on the TeamCity server | ||
## Use blank name to let server generate it. | ||
## By default, this name would be created from the build agent's host name | ||
name=Default Agent | ||
|
||
## Container directory to create default checkout directories for the build configurations. | ||
workDir=/opt/teamcity/agent/work | ||
|
||
## Container directory for the temporary directories. | ||
## Please note that the directory may be cleaned between the builds. | ||
tempDir=/opt/teamcity/agent/temp | ||
|
||
## Container directory for agent system files | ||
systemDir=/opt/teamcity/agent/system | ||
|
||
|
||
###################################### | ||
# Optional Agent Properties # | ||
###################################### | ||
|
||
## The IP address which will be used by TeamCity server to connect to the build agent. | ||
## If not specified, it is detected by build agent automatically, | ||
## but if the machine has several network interfaces, automatic detection may fail. | ||
#ownAddress=<own IP address or server-accessible domain name> | ||
|
||
## Optional | ||
## A port that TeamCity server will use to connect to the agent. | ||
## Please make sure that incoming connections for this port | ||
## are allowed on the agent computer (e.g. not blocked by a firewall) | ||
ownPort=9090 | ||
|
||
## A token which is used to identify this agent on the TeamCity server. | ||
## It is automatically generated and saved on the first agent connection to the server. | ||
authorizationToken=474ba1a15932aafebb296f88372ebd99 | ||
|
||
|
||
###################################### | ||
# Default Build Properties # | ||
###################################### | ||
## All properties starting with "system.name" will be passed to the build script as "name" | ||
## All properties starting with "env.name" will be set as environment variable "name" for the build process | ||
## Note that value should be properly escaped. (use "\\" to represent single backslash ("\")) | ||
## More on file structure: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#load(java.io.InputStream) | ||
|
||
# Build Script Properties | ||
|
||
#system.exampleProperty=example Value | ||
|
||
# Environment Variables | ||
|
||
#env.exampleEnvVar=example Env Value | ||
|
||
#teamcity.git.use.native.ssh=true |
Oops, something went wrong.