JetBrains TeamCity is the main CI/CD service for building, testing and releasing Apache Ignite and it's components.
URL: https://ci.ignite.apache.org/
URL: https://ci2.ignite.apache.org/
Current scheme of keeping consistency between 2 instances of TeamCity instances.
Search for credentialsJSON
settings in repository with settings
grep -R 'credentialsJSON:' .teamcity/ | \ sed -r 's|(.):.param name="(.)".value="(.)" .|\1 :: \2=\3|' | \ sed -r 's| spec=.||'
Search for occurrences of UUIDs in <source-teamcity-host>:/<teamcity-data-dir>/config/project
cd /<source-teamcity-data-dir>/config/project find . -name credentials.json | while read file; do echo "${file}" grep --color -E '(<UUID-1>|UUID-2|...|<UUID-n>)|$' "${file}" done
Copy updated credentials.json
files to some folder
cd /<source-teamcity-data-dir>/config/project mkdir -pv /tmp/credentialsJSON find . -name credentials.json | while read file; do cp -v --parents "${file}" /tmp/credentialsJSON done
Pack secrets in archive
cd /tmp/credentialsJSON zip -r ../credentialsJSON.zip *
<source-teamcity-host>:/<teamcity-data-dir>/config/project
Find local secrets and remove them
cd /<target-teamcity-data-dir>/config/project find . -name credentials.json -exec rm -v {} \; unzip credentialsJSON.zip *
Restart TeamCity instance
cd /<target-teamcity-server-dir> bash bin/teamcity-server.sh stop ... bash bin/teamcity-server.sh start
/<target-teamcity-server-dir>/logs/teamcity-server.log
that TeamCity instance started correctlySynchronization of users, groups and roles requires separate export and import procedure.
Dump specific tables from source TeamCity database
mysqldump --no-tablespaces -u teamcity -p teamcity ids_group \ ids_group_entity_id \ project \ project_mapping \ user_blocks \ user_build_parameters \ user_build_types_order \ usergroup_notification_data \ usergroup_notification_events \ usergroup_roles \ usergroups \ usergroup_subgroups \ usergroup_users \ usergroup_watch_type \ user_notification_data \ user_notification_events \ user_projects_visibility \ user_property \ user_roles \ users \ user_watch_type \ vcs_username > teamcity.sql
/<source-teamcity-data-dir>/config/roles-config.xml
Pack dump and configuration fail into archive
zip -r users-groups-roles.zip teamcity.sql roles-config.xml
<source-teamcity-host>
Unpack archive
unzip users-groups-roles.zip
roles-config.xml
to /<target-teamcity-data-dir>/config/roles-config.xml
Restore specific tables (TeamCity and/or DB service stop is not required)
mysql -u teamcity -p teamcity < teamcity.sql
Stop queue
curl -s \ -u "<tc_username>:<tc_password>" \ -X POST \ "https://<tc_url>/queueStartStop.html?stateChangeReason=TeamCity+daily+maintenance&newQueueState=false"
Wait for non-composite running builds to finish
while true; do runningBuildsCount="$(curl -s \ -u "<tc_username>:<tc_password>" \ -X GET \ "https://<tc_url>/app/rest/builds/?locator=state:running,composite:false" | \ xmllint --format \ --xpath "string(/*[local-name()='builds']/@count)" -)" if [ "$runningBuildsCount" -gt 0 ]; then echo "Running builds left: ${runningBuildsCount}" sleep 60 else break fi done
Restart server
curl -s \ -u "<tc_username>:<tc_password>" \ -X POST \ "https://<tc_url>/admin/serverRestart.html?start=1" 1>/dev/null 2>&1 sleep 10
Wait for TeamCity to boot
while true; do returnCode="$(curl -s \ -I \ -u "<tc_username>:<tc_password>" \ -o /dev/null \ -w "%{http_code}" \ -X GET \ "https://<tc_url>/app/rest/server")" if [ "${returnCode}" != "200" ]; then echo "Current TeamCity HTTP status: ${returnCode}" sleep 60 else break fi done
Resume queue
curl -s \ -u "<tc_username>:<tc_password>" \ -X POST \ "https://<tc_url>/queueStartStop.html?stateChangeReason=&newQueueState=true"
TeamCity server has embedded backup tool which can backup database, project files and settings and build logs and artifacts.
Backup can be done in two ways:
Via REST API:
(optional) Remove old backups
find "<teamcity-data_dir>/backup/" -type f -ctime +<days> -exec rm -rfv {} \; | sed -r 's|^| - |'
Initiate backup
curl -s \ -u "<tc_username>:<tc_password>" \ -X POST \ "https://<tc_url>/app/rest/server/backup?includeConfigs=true&includeBuildLogs=false&fileName=<tc_backup_name>"