-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-58975] - Update the working directory to match container working directory #610
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b6f650f
Rewrite working directory if the container uses a different working d…
narayanan 543f904
Rewrite working directory if the container uses a different working d…
narayanan dff9610
Merge branch 'Fix-Working-Dir-Exec' of github.com:narayanan/kubernete…
narayanan ce5fd04
Added unit tests
narayanan ce46f95
Rewrite working directory if the container uses a different working d…
narayanan 5871cea
Rewrite working directory if the container uses a different working d…
narayanan e916f11
Added unit tests
narayanan 263c171
Merge branch 'Fix-Working-Dir-Exec' of github.com:narayanan/kubernete…
narayanan c3fa703
Fix imports
narayanan b47b7be
Fix imports
narayanan 5d524e7
Modified pwd update logic
narayanan 0378d7a
Fixed spotbug warning
narayanan a2d894c
Merge branch 'master' into Fix-Working-Dir-Exec
Vlatombe d4fe42b
Merge branch 'master' into Fix-Working-Dir-Exec
narayanan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't work if the jnlp container uses a custom working directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vlatombe Setting a custom working directory for JNLP container runs into error much before invoking the kubernetes plugin to execute the shell script. Here is my observation
/home/jenkins/agent
as the workspace directory for declarative pipelines. This is happening becauseKubernetesSlave
setsremoteFs
as default working dir in the following method. When this method gets invoked, YAML declaration of the pod was not yet parsed, so, there is no container so, always sets the default container working dir/home/jenkins/agent
as working directory, basically this directory will not exist within any of the containers.Running on declarative-custom-working-dir-1-0597g-xhtl4-dqklj in /home/jenkins/agent/workspace/declarative Custom Working Dir
remoteFs
directory which will be/home/jenkins/agent
for all declarative pipelines. But with in the JNLP container, workspace is mounted in a different directory, not in the/home/jenkins/agent
. So creation of the shell script in the remote slave fails because that directory does not exist with in JNLP container. This shell script file creation happens with in Jenkins, only after creation of the Shell script control is passed to kubernetes plugin to execute the command.So, my observation is, for declarative pipelines, JNLP container should always use
/home/jenkins/agent
as working directory. Declaring a different one will result in error. I think the right solution would be to set theremoteFs
to the working directory of JNLP. But I think that involves a bigger refactoring as YAML has to be parsed prior to setting theremoteFs
.I think for now, we can treat JNLP containers not able to use a custom working dir as a limitation. Let me know your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They used to be able to - and indeed when upgrading I am no longer able to and my pipelines using kaniko became broken - may or may not have been this change, but changing the workingDir back to the default works (ftr may or may not have been this change - but people with custom jnlp and container images expect to be able to set abitrary working directories) - especially given the field it is still exposed.