Agents are light-weight processes that are installed on hosts and communicate with the UrbanCode Build server.
Agents run commands on the host, move files to and from it, and work with other tools installed on the host. Agents are responsible for running builds and driving third-party tools. After an agent is installed, it opens a socket connection to the server for server-agent communication. Agents can also use the UrbanCode Build web services. After agent communication is established, agent information is displayed in the web-based UI, where it can be configured and modified.
UrbanCode Build Agent in Container
At a time, more than one agent process might be needed for the build process and each of them may have a certain environment configuration. Since it’s a light-weight process, Docker makes it easier to get the Agent containers up and running. The configuration of those containers can be modified easily as per the need. It also allows the server to divide the load accordingly.
Setting up of Agent container
To set the agent containers, download the zip file for agent container and extract it.
The extracted folder contains ibm_ucba_linux_x86_64-version_number.tar.gz file, examples folder and Readme.txt. Import the agent image file into a Docker registry. Use the docker load command to import the agent image files into a Docker registry.
Create the Docker network to connect server and agent containers by using the command:
Now, let’s create the agent container:
Start the container using:
This will by default try to connect to server container (named as ucb-server).
We can check the logs by:
The logs show that it is trying to connect with ucb-server container. If the ucb-server container is running, it will get connected.
If the user wants to connect to server container which has some different then:
Mount an empty conf folder to the /opt/ucb-agent/conf folder while creating the agent container:
By starting the container, the conf folder will get populated.
Now, edit the conf/agent/installed.properties file to connect it with a different server container. Modify the brokenurl and remote.host field with the container name.
Restart the agent container for the changes to take effect.
Check the logs of the container to verify the changes:
Extension or Customization of Agent container
The agent container environment has some basic pre-installed packages like Maven, Ant, Gradle, and Git. But in order to extend its usage, more packages can be installed in the container.
To extend the agent container:
Start an interactive session for the running ucb-agent container as a root user (because only root user has the access to install packages) by:
Now, we are inside the container. Any required package can be installed using the command:
Once the container got new packages, they can be used in their build processes.
In order to create more container having the same configuration, we can create an image from this container by:
Check the latest formed image:
The new image can be tagged with the new name (if needed).
Using agent image and creating containers makes the usage of UrbanCode Build a lot easier. The agent container can also be extended as per the requirement. With docker-compose, the user can bring up the ucb-server and the agent container instantly, and also create as many replicas of agent container as needed. On further extending the use of Docker, the user can apply horizontal scaling which will increase or decrease the number of agent containers as per the load.