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

Question: What is the best way to include plugins in images #33

Open
wbagdon opened this issue Apr 12, 2019 · 3 comments
Open

Question: What is the best way to include plugins in images #33

wbagdon opened this issue Apr 12, 2019 · 3 comments

Comments

@wbagdon
Copy link

wbagdon commented Apr 12, 2019

When starting a cloud agent via the TeamCity Kubernetes plugin, there is a warning:

Some plugins in cloud image are missing/outdated. 
This affects the time necessary to start the agent

What is the best way to get the latest plugins for building a custom image?
Is the only way to copy the plugins dir from an existing updated agent?
Or is there a way to download the buildAgent.zip with plugins from the server?

I was planning on doing something like:

FROM adoptopenjdk/openjdk8:x86_64-ubuntu-jdk8u192-b12

VOLUME /data/teamcity_agent/conf

ENV CONFIG_FILE=/data/teamcity_agent/conf/buildAgent.properties \
    LANG=C.UTF-8

LABEL dockerImage.teamcity.version="latest" \
      dockerImage.teamcity.buildNumber="latest"

COPY run-agent.sh /run-agent.sh
COPY run-services.sh /run-services.sh
ADD https://teamcity/update/buildAgent.zip /opt/buildagent.zip
RUN unzip /opt/buildagent.zip /opt/buildagent

RUN apt-get update && \
    apt-get install -y --no-install-recommends sudo && \
    useradd -m buildagent && \
    chmod +x /opt/buildagent/bin/*.sh && \
    chmod +x /run-agent.sh /run-services.sh && sync

CMD ["/run-services.sh"]

EXPOSE 9090

But buildAgent.zip from the server does not include any plugins.

@magJ
Copy link

magJ commented Mar 15, 2020

I would also like a simple solution to this.
I want to build an agent image with all updates and plugins, is there a simple way to run the agent in an update mode, where it will connect to the server, pull plugins, then disconnect?

@magJ
Copy link

magJ commented Mar 15, 2020

My fragile and hacky solution to this issue, is to run the agent in the build, until I see a particular log line that seems to indicate the update is finished.

#!/bin/bash

echo "Running agent update"

export SERVER_URL="https://example.com"
output=$(mktemp -u)
mkfifo "$output"
# Run agent to fetch updates. Until update is finished
cat "$output"& /run-services.sh | tee "$output" | (grep -q -m 1 -F "Updating agent parameters on the server"; /opt/buildagent/bin/agent.sh stop)
echo "Deleting generated config"
rm -Rf /data/teamcity_agent/conf/*

@pavel-spacil
Copy link

pavel-spacil commented May 20, 2021

Let me add few cents here, I'm downloading plugins based on the list available on update/teamcity-agent.xml and copy the archives to plugins folder in the container. That somehow works as plugins get unzipped and used but few of them are always redownloaded from the server after container start and I was not able to find any pattern why. All are the same archives, the hashes match for baked and downloaded files. Any advice here would be very helpful. Debug log does not say anything valuable, why certain plugins were decided to download again.

EDIT: looks like only the external plugins get redownloaded, so now just to find a reason why and how to fix that

EDIT: so I was able to fix this:

  • have an Dockerfile for init container which downloads plugin archives and teamcity-agent.xml as part of build
  • added this init container and shared volumes to k8s definition and create run script for build agent which checks which plugins are in the image and copy the missing ones + update the teamcity-agent.xml file

Then the agent is started without any downloading of plugins and ready to use 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants