Giter VIP home page Giter VIP logo

teamcity.virtual's Introduction

Docker/Vagrant build runners for TeamCity

Features

Plugin detects and reports installed vagrant and docker

Use the dedicated build runner to run your build script under virtualized environment with help of Docker/Vagrant build runner

License

Apache 2.0

see LICENSE.txt for details

Downloading Build

Download the latest build from TeamCity

Installation

TeamCity Server and TeamCity Build Agents are required to be runnung under JRE 1.7+

To install plugin, put downloaded plugin .zip file into <TeamCity Data Directory>/plugins folder and restart TeamCity Server.

Make sure downloaded .zip file is not corrupted and is not sources .zip from GitHub.

For more details, there is documentation

Supported Versions

Plugin is tested to work with TeamCity 8.1. It should work with 8.0 (and maybe 7.1.x)

Agent and server are expected to run JRE 1.7

Building

  • call ant -f fetch.xml fetch
  • open the project in IntelliJ IDEA 13.1
  • make all artifacts

In this repo you will find

  • TeamCity server and agent plugin bundle
  • Plugin version will be patched if building with IDEA build runner in TeamCity
  • Run configuration server to run/debug plugin under TeamCity (use http://localhost:8111/bs)
  • pre-configured IDEA settings to support references to TeamCity
  • Uses $TeamCityDistribution$ IDEA path variable as path to TeamCity home (unpacked .tar.gz or .exe distribution)
  • Bunch of libraries for most recent needed TeamCity APIs
  • Module with TestNG tests that uses TeamCity Tests API

For details see https://github.com/jonnyzzz/TeamCity.PluginTemplate

Dependencies fetch via simple-maven

This is simple possible ant script that could be used to fetch maven dependencies in Intellij IDEA based projects.

Call fetch.xml to fetch all missing dependencies

The script also updates IDEA library files to include new-ly added libraries to IDEA project. It's expected you'll no changed files on script re-run. If you do => post the issue with diff

We use Maven Ant Tasks inside. So <dependency> element under <maven-fetch> is the same element as under Maven Ant Tasks

For details see https://github.com/jonnyzzz/intellij-ant-maven

Notice

Some code of this plugin was borrowed from NuGet plugin which is licensed under Apache 2.0

Note

This plugin was created with [https://github.com/jonnyzzz/TeamCity.PluginTemplate](TeamCity Plugin Template)

This is my (Eugene Petrenko) private home project

teamcity.virtual's People

Contributors

jonnyzzz avatar krlmlr avatar mrtimuk avatar nd avatar ruudk avatar shalupov avatar streaming avatar vbedrosova avatar winglot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

teamcity.virtual's Issues

docker kill hangs sometimes on execution timeout

Some builds on our internal build server hangs like this:

[14:44:44][Step 2/3] docker: Executing the command (2h:59m:09s)
[14:44:44][docker] Executing command: docker run --rm=true --name=teamcity_CZFp4yl2IyqBbkAmQl8jzMw4cE3QEIPV -v /opt/buildAgent/work/1605adbb0f4184ad:/jonnyzzz:rw --workdir=/jonnyzzz/Rider --interactive=false --tty=false --cap-add=SYS_PTRACE --security-opt=seccomp:unconfined -e "LANG=ru_RU.UTF-8" -e "LANGUAGE=ru_RU.UTF-8" -e "LC_ALL=ru_RU.UTF-8" docker-registry.labs.intellij.net/jetbrains/rider-tests /bin/bash -c "source teamcity3793080446078476487.build.cmd"
[14:44:44][docker] Starting: /opt/buildAgent/temp/agentTmp/custom_script5339719823805135308
[14:44:44][docker] in directory: /opt/buildAgent/work/1605adbb0f4184ad
[17:43:53][docker] The build Rider::Tests - Linux (Docker) RUS #163.10888 {buildId=14941058} has been running for more than 180 minutes. Terminating...
[17:43:53][docker] Error message is logged
[17:43:53][docker] Execution timeout
[17:43:53][docker] Dumping threads before termination:
[17:43:53][docker] PID: 24358, PPID: 17108, Command line: /bin/sh /opt/buildAgent/temp/agentTmp/custom_script5339719823805135308
[17:43:53][docker] Failed to locate jps tool. No thread dump information is available
[17:43:53][docker] 
[17:43:53][docker] PID: 24359, PPID: 24358, Command line: docker run --rm=true --name=teamcity_CZFp4yl2IyqBbkAmQl8jzMw4cE3QEIPV -v /opt/buildAgent/work/1605adbb0f4184ad:/jonnyzzz:rw --workdir=/jonnyzzz/Rider --interactive=false --tty=false --cap-add=SYS_PTRACE --security-opt=seccomp:unconfined -e LANG=ru_RU.UTF-8 -e LANGUAGE=ru_RU.UTF-8 -e LC_ALL=ru_RU.UTF-8 docker-registry.labs.intellij.net/jetbrains/rider-tests /bin/bash -c source teamcity3793080446078476487.build.cmd
[17:43:53][docker] Failed to locate jps tool. No thread dump information is available
[17:43:53][docker] 
[17:43:53][docker] PID: 23741, PPID: 17108, Command line: perl /opt/buildAgent/system/perfmon/scripts/vmstatlinux.pl /opt/buildAgent/system/perfmon/temp/perfmon.csv 1000
[17:43:53][docker] Failed to locate jps tool. No thread dump information is available
[17:43:53][docker] 
[17:43:53][docker] PID: 23745, PPID: 23741, Command line: vmstat 1
[17:43:53][docker] Failed to locate jps tool. No thread dump information is available
[17:43:53][docker] 
[17:43:53][docker] Process exited with code 137
[17:43:54][docker] Process exited with code 137
[17:43:53][Step 2/3] docker: Terminating images (if needed) (running for 95h:44m:55s)
[17:43:53][docker] Executing command: docker kill teamcity_CZFp4yl2IyqBbkAmQl8jzMw4cE3QEIPV 2>&1 || true
[17:43:53][docker] Failed to start process to monitor system performance. Performance monitoring data will not be available.
[17:43:53][docker] Starting: /opt/buildAgent/temp/agentTmp/custom_script1135678515648543366
[17:43:53][docker] in directory: /opt/buildAgent/work/1605adbb0f4184ad

Domain name already taken

From time to time I run into the issue of having a domain already created:

agent@prodtestagent:~$ vagrant up 99b879d
Bringing machine 'default' up with 'libvirt' provider...
Name `f61a661addc9b31f_default` of domain about to create is already taken. Please try to run
`vagrant up` command again.

Running virsh list results in

virsh # list
 Id    Name                           State
----------------------------------------------------
 5     f61a661addc9b31f_default       running

But then destroying that domain and trying to vagrant up or even vagrant destroy results in the same error.

I mostly run into the issue if a test fails at an early stage (around vagrant up).

Anybody an idea what reason that has?

Is possible to use port forwarding?

Hi

Is it possible to use port forwarding so I can access a service running in docker say on port 8080 from another build step? I have some .net integration tests that rely on talking to an instance of elastic and I was hoping I could fire up a container of elastic run the tests and dispose of it.

Any tips / advice much appreciated.

build.cmd file not found

Running TeamCity 2017.1, the docker run command looks something like this:

docker run --rm=true --name=teamcity_s2L51dkQVAmqIyuOVabB5iKq0hbPQR4D -v /opt/buildagent/work/5a079a74598fd4f:/checkout:rw --workdir=/checkout/ --interactive=false --tty=false blang/busybox-bash /bin/bash -c "source teamcity6360598547668335939.build.cmd

But this fails because /bin/bash: teamcity6360598547668335939.build.cmd: No such file or directory. Indeed no such file is in the working directory (or anywhere on the agent for that matter). I can see in the code where this is supposed to happen, but something isn't working. Is this an incompatibility with the newer TeamCity?

How to start docker container with local image ?

How do I start docker container with local image ?

For example I have got this at the moment:
[root@tcagent docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
image tag 6584e9c5cc79 44 minutes ago 1.347 GB

How can I start image/tag ? I been trying to get this working for the past 30minutes, no joy!

Would be great to have more examples how to use (and especially build) this plugin >>Author

thanks

Better default shell

Now it's /bin/bash, would be better to change to /bin/sh, according to UNIX standards.
Linux well compatible with this, has a /bin/sh-to-bash symbolic link.

No not write 'error' in finally step

Current log is

             [10:22:21][Step 5/5] docker: Terminating images (if needed)
             [10:22:21][docker] Executing command: docker kill teamcity_tJkCfFeZ97f6tJHLLKePbM4VAYXYaWS8 2>&1 || true
             [10:22:21][docker] Starting: /home/builduser/buildAgent/temp/agentTmp/custom_script1247262640453440513
             [10:22:21][docker] in directory: /home/builduser/buildAgent/work/dcfccd8c4beb0fd0
             [10:22:21][docker] Error: No such container: teamcity_tJkCfFeZ97f6tJHLLKePbM4VAYXYaWS8
             [10:22:21][docker] 2014/05/06 12:22:20 Error: failed to kill one or more containers
             [10:22:21][docker] Process exited with code 0

This makes build script contain 'error' that frighten end-users

osx support

When trying to register an OSX TC agent with docker installed, the docker configuration parameter does not appear, thus the agent cannot run build step with the runner.
Are osx agents supported by the plugin?

how to use this plugin

Hi,

I am newbie for this plugin. Is there any wiki or documents on how to use this plugin to run a build in team city?

Thanks

Shawn

Vagrant: Manual configuration of Vagrantfile

It would be nice to have a configuration field where you can define a custom value for the string that is appended at the end of the existing vagrantfile. Or a possibility to override the existing Vagrantfile.

It would then be possible to test on multiple vagrant machines using a single build configuration.

I would like to implement that feature, but I somehow missed the class where the Vagrantfile-string is generated. Any hints?

Support for Docker Login?

Was just having a look for the screenshots for this, does the plugin support docker login?

We have an internal docker registry that requires docker login to docker pull images, could we get this feature added in?

Fixing chown takes a lot of time

Hi,
Sometimes theFixing chown step can take way too long. In our builds it sometime takes more than ten minutes.
Is there something we can do about it?

Thanks

Sometimes working copy is left in unclean state

By unclean state I mean files and directories owned by other users (like root).

This leads to broken subsequent builds and taking disk space (which could not be cleaned up by TeamCity agent)

docker returned exit code 1 and build is successful

Logs:

[17:31:51]W: Step 2/2: Docker / Vagrant
[17:31:51]i:     [Step 2/2] ##teamcity[buildStatisticValue key='buildStageDuration:buildStepRUNNER_1665' value='0.0']
[17:31:51] :     [Step 2/2] Staring Docker…
[17:31:51]W:     [Step 2/2] The build runner requires to enable 'the build process exit code is not zero' build failure condition
[17:31:51]W:     [Step 2/2] docker: Pulling the image
[17:31:51] :         [docker] Executing command: docker pull docker-registry.labs.intellij.net/jetbrains/webdriver-java
[17:31:51] :         [docker] Starting: /home/builduser/buildAgent/temp/agentTmp/custom_script3286697805688716087
[17:31:51] :         [docker] in directory: /home/builduser/buildAgent/work/9647f0fc8c6750f
[17:31:52] :         [docker] Pulling repository docker-registry.labs.intellij.net/jetbrains/webdriver-java
[17:31:52]W:         [docker] 2014/11/30 16:31:52 HTTP code: 502
[17:31:52]W:         [docker] Process exited with code 1
[17:31:52]W:     [Step 2/2] docker: Executing the command
[17:31:52] :         [docker] Executing command: docker run --rm=true --name=teamcity_NUUjTw1iytaacSpYtawWJFdOWHONVBbB -v /home/builduser/buildAgent/work/9647f0fc8c6750f:/jonnyzzz:rw --workdir=/jonnyzzz/ --interactive=false --tty=false -p 8080:8080 -p 3022:22 -p 5900:5900 -p 5901:5901 docker-registry.labs.intellij.net/jetbrains/webdriver-java /bin/bash -c "source teamcity1313250188038849798.build.cmd"
[17:31:52] :         [docker] Starting: /home/builduser/buildAgent/temp/agentTmp/custom_script3994928412794285499
[17:31:52] :         [docker] in directory: /home/builduser/buildAgent/work/9647f0fc8c6750f
[17:31:52]W:         [docker] Unable to find image 'docker-registry.labs.intellij.net/jetbrains/webdriver-java' locally
[17:31:52]W:         [docker] Pulling repository docker-registry.labs.intellij.net/jetbrains/webdriver-java
[17:31:52]W:         [docker] 2014/11/30 16:31:52 HTTP code: 502
[17:31:52]W:         [docker] Process exited with code 1
[17:31:52] :     [Step 2/2] docker: Terminating images (if needed)
[17:31:52] :         [docker] Executing command: docker kill teamcity_NUUjTw1iytaacSpYtawWJFdOWHONVBbB 2>&1 || true
[17:31:52] :         [docker] Starting: /home/builduser/buildAgent/temp/agentTmp/custom_script8861153091189038288
[17:31:52] :         [docker] in directory: /home/builduser/buildAgent/work/9647f0fc8c6750f
[17:31:52] :         [docker] Error: No such container: teamcity_NUUjTw1iytaacSpYtawWJFdOWHONVBbB
[17:31:52] :         [docker] 2014/11/30 16:31:52 Error: failed to kill one or more containers
[17:31:52] :         [docker] Process exited with code 0
[17:31:52]W:     [Step 2/2] docker: Fixing chown
[17:31:52] :         [docker] Executing command: docker run --rm=true --name=teamcity_NUUjTw1iytaacSpYtawWJFdOWHONVBbBS -v /home/builduser/buildAgent/work/9647f0fc8c6750f:/jonnyzzz:rw --workdir=/jonnyzzz/ --interactive=false --tty=false docker-registry.labs.intellij.net/jetbrains/webdriver-java /bin/bash -c "chown -R 502:502 ."
[17:31:52] :         [docker] Starting: /home/builduser/buildAgent/temp/agentTmp/custom_script4434308513199197590
[17:31:52] :         [docker] in directory: /home/builduser/buildAgent/work/9647f0fc8c6750f
[17:31:52]W:         [docker] Unable to find image 'docker-registry.labs.intellij.net/jetbrains/webdriver-java' locally
[17:31:52]W:         [docker] Pulling repository docker-registry.labs.intellij.net/jetbrains/webdriver-java
[17:31:52]W:         [docker] 2014/11/30 16:31:52 HTTP code: 502
[17:31:52]W:         [docker] Process exited with code 1

Make sure build agent is able to remove docker flies

Let's make an extension for build agent to make sure it cleans .old folder under same permissions as docker container may have on the host

Current approach with running chmod may break permissions on the host

We may check -v argument to find the whole list of paths we need to check

Detect Docker on non-Linux platforms

The detectDocker method does not detect the docker client on platforms other than Linux, which prevents the docker remote client being used on, e.g. Mac OS X such as with boot2docker. The following code should be removed:

if (!SystemInfo.isLinux) {
  LOG.debug("Docker is only available under Linux");
  return;
}

Directory Separator in Windows

When using this plugin in Windows, i encountered a problem relating to directory separator.
As commonly vagrant using "/" instead of "" as directory separator, i found that my working directory :

C:\TeamCity\buildAgent\work\2f4edc276fdfd1e8

is translated by vagrant to to:

C:TeamCity uildAgentwork f4edc276fdfd1e8

Attached my log files relating to this issue

KLOG_Web_App_Build_via_Vagrant_22.txt

docker: Allow overriding/setting workdir

As show below, the working directory, including related volume mounting is hard-coded and it would be great if there was a way to override this with custom workdir argument (presumably just pointing to any absolute path within the container).

arguments.addAll(Arrays.asList(
"docker",
"run",
"--rm=true",
"--name=" + name,
"-v",
checkoutDir.getPath() + ":" + mountPoint + ":" + ctx.getDockerMountMode(),
"--workdir=" + mountPoint + "/" + RelativePaths.resolveRelativePath(checkoutDir, workDir),
"--interactive=false",
"--tty=false"));
arguments.addAll(dockerArgs);
arguments.add(ctx.getImageName());
arguments.addAll(command);

problem when running build-agents with non-root user

Hi! We are running our TeamCity Build Agents with a non-root user. Sadly this causes some errors with your plugin:

[11:19:35]	[Step 1/1] Starting Docker…
[11:19:35]	[Step 1/1] docker: Pulling the image
[11:19:35]	[docker] Executing command: docker pull guyton/rpm-buildhost-el6
[11:19:35]	[docker] Starting: /home/teamcity/buildAgent/temp/agentTmp/custom_script5319847607262460378
[11:19:35]	[docker] in directory: /home/teamcity/buildAgent/work/a49d8d29bcc8a7ae
[11:19:35]	[docker] Using default tag: latest
[11:19:35]	[docker] Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon. Is the docker daemon running on this host?). Using system default: https://index.docker.io/v1/
[11:19:35]	[docker] Cannot connect to the Docker daemon. Is the docker daemon running on this host?
[11:19:35]	[docker] Process exited with code 1
[11:19:37]	[Step 1/1] docker: Fixing chown
[11:19:37]	[docker] Executing command: docker run --rm=true --name=teamcity_PwNNEE7jzZJk7fctXQDxHqyEM00tb6P7S -v /home/teamcity/buildAgent/work/a49d8d29bcc8a7ae:/checkout:rw --workdir=/checkout/ --interactive=false --tty=false guyton/rpm-buildhost-el6 /bin/bash -c "chown -R 1000:1000 ."
[11:19:37]	[docker] Starting: /home/teamcity/buildAgent/temp/agentTmp/custom_script8563996444722791275
[11:19:37]	[docker] in directory: /home/teamcity/buildAgent/work/a49d8d29bcc8a7ae
[11:19:37]	[docker] docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
[11:19:37]	[docker] See 'docker run --help'.
[11:19:37]	[docker] Process exited with code 125

If I run this command as teamcity user on my build-agent I also get an error:

docker run --rm=true --name=teamcity_PwNNEE7jzZJk7fctXQDxHqyEM00tb6P7S -v /home/teamcity/buildAgent/work/a49d8d29bcc8a7ae:/checkout:rw --workdir=/checkout/ --interactive=false --tty=false guyton/rpm-buildhost-el6 /bin/bash -c "chown -R 1000:1000 ."

If I add -u root it works fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.