From 0f28de2beeefcf0e1914af28b51f1919ec3ad1aa Mon Sep 17 00:00:00 2001 From: samuel Date: Tue, 2 May 2023 11:46:23 +0200 Subject: [PATCH] [Dev] Add repo hash or tag in pipeline sock directory --- src/pipeline.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pipeline.sh b/src/pipeline.sh index 005964f..8db2282 100755 --- a/src/pipeline.sh +++ b/src/pipeline.sh @@ -215,24 +215,23 @@ main() ( "${err_pipeline_sock_dir_not_writable}" fi - # Generate pipeline tmp sock. - tsp="$(date +%s)" - random="$(echo "${RANDOM}" | md5sum | head --bytes 32)" - rd_pipeline_sock_dir="${pipeline_sock_dir}/${pipeline}-${tsp}-${random}" - rd_pipeline_sock="${rd_pipeline_sock_dir}/pipeline.sock" + # Generate random string. + random="$(echo "${RANDOM}" | md5sum | head --bytes 8)" # Build runner request. case "${pipeline}" in newcommit) + rd_pipeline_sock_dir="${pipeline_sock_dir}/${pipeline}-${repo_hash}-${random}" runner_request="$(jq --null-input --compact-output \ - --arg s "${rd_pipeline_sock}" \ + --arg s "${rd_pipeline_sock_dir}/pipeline.sock" \ --arg n "${repo_name}" \ --arg h "${repo_hash}" \ '{"response_sock":$s,"repo_name":$n,"repo_hash":$h}')" ;; newtag) + rd_pipeline_sock_dir="${pipeline_sock_dir}/${pipeline}-${repo_tag}-${random}" runner_request="$(jq --null-input --compact-output \ - --arg s "${rd_pipeline_sock}" \ + --arg s "${rd_pipeline_sock_dir}/pipeline.sock" \ --arg n "${repo_name}" \ --arg h "${repo_hash}" \ --arg t "${repo_tag}" \ @@ -254,17 +253,18 @@ main() ( ( inotifywait --timeout 1 --quiet --quiet \ --event create "${rd_pipeline_sock_dir}" || true - chmod 775 "${rd_pipeline_sock}" - chgrp "${git_runner_groupname}" "${rd_pipeline_sock}" + chmod 775 "${rd_pipeline_sock_dir}/pipeline.sock" + chgrp "${git_runner_groupname}" "${rd_pipeline_sock_dir}/pipeline.sock" echo "${runner_request}" | ncat --unixsock "${runner_sock}" ) & # Wait for runner response. + cd "${rd_pipeline_sock_dir}" if [ "${runner_timeout}" -gt 0 ]; then response="$(timeout "${runner_timeout}" ncat --listen \ - --unixsock "${rd_pipeline_sock}")" + --unixsock pipeline.sock)" else - response="$(ncat --listen --unixsock "${rd_pipeline_sock}")" + response="$(ncat --listen --unixsock pipeline.sock)" fi # Remove random directory.