A
A
Alexander Karpov2020-09-08 16:46:57
Jenkins
Alexander Karpov, 2020-09-08 16:46:57

Why is Jenkins running a job endlessly?

Created a job with free configurations and set up source control.
As Branches to build (Branch Specifier (blank for 'any'))
:^origin\/hotfix\-order\-html\-(.*)$
I thought it worked fine, but then I noticed that the job started spontaneously.
The build trigger of course is "Poll SCM for changes", on schedule
H/10 * * * *

Maybe someone can tell me if I need the job to react to new branches or changes to the current ones according to the template above. In general it works, but why it runs the build without a change in the repository - I don't know.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karpov, 2020-09-10
@Inkognitoss

In the end, I had to use a webhook.
For some reason, if I use a regular expression, the $GIT_BRANCH environment variable seems to contain an irrelevant match (for some reason, a branch of a previous job build). And apparently, the change trigger in the SCM works endlessly.
When using webhooks, the $gitlabBranch environment variable is available to me, and the regular expression itself is already registered in the job's webhook settings.
also, just in case, in the shell script that I run as part of a specific job, I check for the presence of $gitlabBranch

if [ -n "${gitlabBranch}" ]; then
  echo "gitlabBranch is set ${gitlabBranch}"
else
    echo "gitlabBranch isn't set"
    exit 1
fi

this was necessary so that the job did not continue the build if $gitlabBranch is missing (for example, if you run it manually). Previously (when I thought that everything worked anyway), when manually building, the assembly of the last branch that matched the regular expression was simply launched. If I figure out what's wrong and where I made a mistake, I'll share.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question