Sending Build Info
Overview
If projects require artifacts that are not publicly accessible, or have unique environmental requirements that preclude agents from gathering build information, the send_build_info.sh
script can be used to send build information to the CodeLogic server.
It is run in the Git working tree and sends the following information gathered from Git:
- Git author
- Git author email
- Git branch
- Git commit hash
- Git commit message
- Git repository URL
The script also sends this information, specified by the user:
- Build log
- Build number
- Build status
- Job name
- Node name
- Pipeline system
Important: The script only works with pre-authorized agents. That is, agents that are created from the CodeLogic UI.
Create an Agent in the CodeLogic UI
Navigate to the Agents
page from the side navigation bar in the CodeLogic UI
Create a new agent by clicking Create Agent
on the Agents
page and giving the agent a name and optional description.
Note the Agent ID
and Password
, or leave this modal open.
Installation
There are multiple ways to install the send_build_info.sh
script:
Through the UI
Download the script under Store
> Miscellaneous
Directly from the CodeLogic server
For Linux systems, you can use the following command:
wget ${SERVER_LOCATION}/codelogic/server/packages/send_build_info.tar -O /tmp/send_build_info.tar && tar -xvf /tmp/send_build_info.tar -C /tmp
Operation
$ ./send_build_info.sh --help
Usage: send_build_info.sh [OPTIONS]...
Send build information to the CodeLogic server.
This script is intended for environments in which build information is not
accessible. Use it to send git and other information to the CodeLogic server.
The Agent ID and password are supplied by the CodeLogic server when an agent
is created manually in Agents > Create Agent.
It must be run from within your Git working tree directory.
Required Options:
-a, --agent-id=AGENT_ID Agent ID for CodeLogic server authentication
-p, --agent-password=PASSWORD password for the agent (will prompt if not specified, to avoid
storing in command line history, timeout after 300 seconds)
-s, --server=SERVER_URL the full URL of the CodeLogic server (supports both HTTP and HTTPS)
(e.g., http://192.168.86.50 or https://codelogic-server.example.com),
if not specified, the script tries to determine it from the installation file
Optional Options:
-b, --build-number=NUMBER specify the build number (default: 1)
-d, --dry-run print planned work without executing
-f, --log-file=FILE specify a log file to use instead of creating one. The last 1000 lines
of the log file will be sent (use -n/--log-lines to customize). If not specified,
a file will be created with job-name, build-number, build-status, pipeline-system,
hostname, and user.
-i, --pipeline-system=SYSTEM specify the pipeline system (default: Custom),
other options: Custom, Jenkins, GitHub Actions, GitLab CI/CD, etc.
-j, --job-name=JOB_NAME specify the job name (default: unknown-job)
-n, --log-lines=NUMBER specify the number of trailing lines to send from the log file (default: 1000, min: 5, max: 2000).
This option is only used when a log file is specified using --log-file.
-t, --build-status=STATUS specify the build status (default: SUCCESS)
-v, --verbose run with extra logging
-h, --help display this help and exit
Examples:
# Basic usage, from a Git working tree directory
./send_build_info.sh -a "agentid" -p "agentpassword" -s "https://codelogic-server.example.com" -f "/path/to/build.log"
# Using long flag for server, from a Git working tree directory, default build log file
./send_build_info.sh --agent-id="agentid" --agent-password="agentpassword" --server="https://codelogic-server.example.com"
# Long option with equals sign
./send_build_info.sh --agent-id="agentid" --agent-password="agentpassword" --server="http://192.168.86.50" --job-name="my-job" --log-file="/path/to/build.log"
# Verbose mode
./send_build_info.sh -v -a "agentid" -p "agentpassword" -s "https://codelogic-server.example.com" -j "build-job" -b 456 -t "SUCCESS" -i "Jenkins"
# Basic usage with required credentials, --server is optional if the server or agents are installed and configured
./send_build_info.sh -a "agentid" -p "agentpassword" --log-file="/path/to/build.log"
# Using custom log file with specific number of lines, --server is optional if the server or agents are installed and configured
./send_build_info.sh --agent-id="agentid" --agent-password="agentpassword" --log-lines=500 --log-file="/path/to/build.log"