Jenkinsfile: set repo and branch, to assist validate_diff()#40035
Jenkinsfile: set repo and branch, to assist validate_diff()#40035thaJeztah merged 1 commit intomoby:masterfrom
Conversation
e855e85 to
b6df91f
Compare
This is a continuation of 2a08f33; When running CI in other repositories (e.g. Docker's downstream docker/engine repository), or other branches, the validation scripts were calculating the list of changes based on the wrong information. This lead to weird failures in CI in a branch where these values were not updated ':-) (CI on a pull request failed because it detected that new tests were added to the deprecated `integration-cli` test-suite, but the pull request did not actually make changes in that area). This patch uses environment variables set by Jenkins to sets the correct target repository (and branch) to compare to. Signed-off-by: Sebastiaan van Stijn <[email protected]>
e4a564a to
7019b60
Compare
|
Ok, this looks good; from a debug line that I just removed, the variables look to be set properly inside the container; |
| -e DOCKER_GITCOMMIT=${GIT_COMMIT} \ | ||
| -e DOCKER_GRAPHDRIVER \ | ||
| -e VALIDATE_REPO=${GIT_URL} \ | ||
| -e VALIDATE_BRANCH=${CHANGE_TARGET} \ |
There was a problem hiding this comment.
FWIW; I tried setting these as global variable in the Jenkinsfile, but the Git plugin does not expose it's variables at that point, so while we can get CHANGE_TARGET, we can't get GIT_URL (without additional hackery), so I went for just passing them here inline
There was a problem hiding this comment.
To clarify; I assumed Jenkins would set that env-var for the whole job, but the Git plugin only sets it after if does the checkout, so it's only present in the stages itself.
My initial attempt was to map those env-vars in the top level block;
environment {
DOCKER_BUILDKIT = '1'
DOCKER_EXPERIMENTAL = '1'
DOCKER_GRAPHDRIVER = 'overlay2'
APT_MIRROR = 'cdn-fastly.deb.debian.org'
CHECK_CONFIG_COMMIT = '78405559cfe5987174aa2cb6463b9b2c1b917255'
TESTDEBUG = '0'
TIMEOUT = '120m'
TIMEOUT = '120m'
TIMEOUT = '120m'
VALIDATE_REPO = "${env.GIT_URL}"
VALIDATE_BRANCH = "${env.CHANGE_TARGET}""
}
Which worked for $CHANGE_TARGET / VALIDATE_BRANCH, but VALIDATE_REPO would always be NULL
kolyshkin
left a comment
There was a problem hiding this comment.
LGTM
(Every time I look at repetitive things like this, I think Jenkins must have an ability to do functions, or templates, or something -- alas, I looked at it once and it felt way too complicated)
|
@kolyshkin yes (also see above on setting the env-var globally). Unfortunately that isn't there yet for the declarative pipelines; you can create an account, and vote for JENKINS-40986 though (I did that earlier today) |
|
This is green; let me merge it |
This is a continuation of 2a08f33 (#38655);
When running CI in other repositories (e.g. Docker's downstream docker/engine repository), or other branches, the validation scripts were calculating the list of changes based on the wrong information.
This lead to weird failures in CI in a branch where these values were not updated ':-) (CI on a pull request failed because it detected that new tests were added to the deprecated
integration-clitest-suite, but the pull request did not actually make changes in that area).This patch uses environment variables set by Jenkins to sets the correct target repository (and branch) to compare to.