- job: name: tcwg-abe-test-container project-type: freestyle defaults: global logrotate: daysToKeep: 30 numToKeep: 30 properties: - authorization: anonymous: - job-read - job-extended-read linaro: - job-build - job-cancel parameters: - string: name: container_user default: tcwg-buildslave description: 'Non-root user inside container' - string: name: public_key default: '' description: 'SSH public key. Leave empty to not install additional public keys or use "ldap" to fetch from LDAP' - string: name: upstream_dest default: '' description: 'SSH destination to write connection parameters to, e.g., dev-01.tcwglab:/tmp/my-abe-test-container.param. Location must be writable by tcwg-buildslave.' disabled: false node: docker-trusty-i386-tcwg concurrent: true display-name: 'TCWG ZZZ ABE Test Container' wrappers: - timeout: timeout: 600 - timestamps - ssh-agent-credentials: # tcwg-buildslave user id users: - 'e0958a95-204f-4c14-a66c-5e2be6c5d50a' - build-name: name: '#${BUILD_NUMBER}' builders: - shell: | #!/bin/bash set -ex if [ x"$public_key" = x"ldap" ]; then public_key="$(ssh -o StrictHostKeyChecking=no aus-colo.linaro.org /etc/ssh/ssh_keys.py $container_user)" fi if [ x"$public_key" != x"" ]; then echo "" >> ~/.ssh/authorized_keys || true echo "$public_key" >> ~/.ssh/authorized_keys || true fi if ! getent passwd $container_user; then container_user_data="$(ssh -o StrictHostKeyChecking=no aus-colo.linaro.org getent passwd $container_user)" container_user_uid="$(echo "$container_user_data" | cut -d: -f 3)" if [ x"$container_user_uid" != x"" ]; then container_user_uid_opt="-u $container_user_uid" fi sudo useradd -m $container_user_uid_opt $container_user sudo rsync -a ~/.ssh/ /home/$container_user/.ssh/ sudo chown -R $container_user /home/$container_user/.ssh/ fi sudo touch /keep-container sudo chmod 0777 /keep-container echo "1" > /keep-container docker_host="$(echo $DOCKER_HOST | sed -e "s#^tcp://\(.*\):.*#\1#")" docker_host="$(echo $docker_host | sed -e "s/-x86//")" ssh_port="$(ssh $docker_host docker port $DOCKER_CONTAINER_ID 22)" ssh_port="$(echo $ssh_port | cut -d: -f 2)" if [ x"$upstream_dest" != x"" ]; then upstream_machine="$(echo "$upstream_dest" | cut -d: -f 1)" upstream_file="$(echo "$upstream_dest" | cut -d: -f 2)" echo "$container_user@$docker_host:$ssh_port" | ssh $upstream_machine tee $upstream_file > /dev/null fi set +x echo "Testing container: $container_user@$docker_host:$ssh_port" echo "To stop container run: ssh -o Port=$ssh_port $container_user@$docker_host sh -c 'echo 0 > /keep_container'" echo "Hosting tests" while [ -e /keep-container ] && [ x"$(cat /keep-container)" = x"1" ]; do sleep 60 echo "Running processes: $(ps ax | wc -l)" done echo "Exiting"