Environment
-
CloudBees Jenkins Enterprise - Managed controller (CJE-MM)
-
CloudBees Jenkins Enterprise - Operations center (CJE-OC)
Resolution
Elasticsearch (ES) store documents into indices, so you need to create a index on ES, then you be able to send data through the REST API.
This command create a index named custom_builds
in the es.example.com:9200
ES server.
curl -u USERNAME:PASSWORD -XPUT 'es.example.com:9200/custom_builds?pretty'
This command create a JSON file with some environment variables of the build, and send the data to the es.example.com:9200
ES server. You could put this script in a shell step in a FreeStyle job or in a sh
step in a Pipeline job.
cat > message.json <<EOF { "enviroment": "$ENV", "build_number": "$BUILD_NUMBER", "build_tag": "$BUILD_TAG", "job_base_name": "$JOB_BASE_NAME", "job_name": "$JOB_NAME", "node_name": "$NODE_NAME", "node_labels": "$NODE_LABELS", "status": "SUCCESS", "date": "$(date +%Y%m%d-%H:%M:%S)" } EOF curl -u USERNAME:PASSWORD -XPUT 'es.example.com:9200/custom_builds/external/1?pretty' -d '@message.json'