[JENKINS-75902] Always save a timestamp of the latest GitLab project configurations into the config, signalling this plugin has done some work #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change continues the work done in jenkinsci#495.
We found that this plugins'
GitLabSCMSource#retrieve()
methods are called when the job-dsl-plugin'sjobDsl()
method is called.If at those points the code in this plugin fails to communicate with GitLab, the
config.xml
file corresponding to the pipeline being parsed is saved without any information that would come from this project's GitLab project (i.e.:sshRemote
,httpRemote
,projectId
will not exist). The contents of that file will be the same as if this plugin hadn't executed.When the
jobDsl()
method is called again at a later time, it compares the savedconfig.xml
to theconfig.xml
it expects to save at that point. See https://github.com/jenkinsci/job-dsl-plugin/blob/master/job-dsl-plugin/src/main/java/javaposse/jobdsl/plugin/JenkinsJobManagement.java#L453.Note that at that point, the new expected
config.xml
that the job-dsl-plugin uses for that diff does not have any information that should come from the gitlab-branch-source-plugin.As such, at that point both the base
config.xml
as well as the expected-to-saveconfig.xml
are equal.This change adds a new field to the pipeline's configuration,
lastRetrieveTimestamp
, that is updated at every attempt to update it, regardless of the GitLab communication having succeeded or not. In this way, the attempteddiff
by the job-dsl-plugin will always trigger an update and corresponding reattempt at communicating with GitLab, preventing previous failures from avoiding that.Testing done
Similarly to jenkinsci#495, we deployed a patched gitlab-branch-source-plugin with both that and this change into our running Jenkins. We have not seen the issue reoccurring and will keep on observing it in the next weeks. We will notify if we see this wasn't effective.
Submitter checklist