-
Bug
-
Resolution: Unresolved
-
Minor
-
None
We use the kubernetes plugin with enterprise jenkins. As soon as developers refer to one of their containers from their pod template, the first thing they usually want to do is to cd into a certain directory. What's the best way to do this in order to avoid making them do a "cd" over and over again in their sh'es? The dir() function does not work unfortunately (perhaps it only works in the jenkins jnlp container?)
Ideally we could do something like this:
container(name: 'mycontainer', dir: "/home/app/foo") { ... }
or...
container(name: 'mycontainer') { dir("/home/app/foo") { ... } }
[JENKINS-60396] Setting default directory when using container()
Description |
Original:
We use the kubernetes plugin with enterprise jenkins. As soon as developers refer to one of their containers from their pod template, the first thing they usually want to do is to cd into a certain directory. What's the best way to do this in order to avoid making them do a "cd" over and over again in their sh'es? The dir() function does not work unfortunately (perhaps it only works in the jenkins jnlp container?) Ideally we could do something like this: contatiner(name: 'mycontainer', dir: "/home/app/foo") { ... } or... contatiner(name: 'mycontainer') { dir("/home/app/foo") { ... } } |
New:
We use the kubernetes plugin with enterprise jenkins. As soon as developers refer to one of their containers from their pod template, the first thing they usually want to do is to cd into a certain directory. What's the best way to do this in order to avoid making them do a "cd" over and over again in their sh'es? The dir() function does not work unfortunately (perhaps it only works in the jenkins jnlp container?) Ideally we could do something like this: ``` contatiner(name: 'mycontainer', dir: "/home/app/foo") { ... } ``` or... contatiner(name: 'mycontainer') { dir("/home/app/foo") { ... } } |
Description |
Original:
We use the kubernetes plugin with enterprise jenkins. As soon as developers refer to one of their containers from their pod template, the first thing they usually want to do is to cd into a certain directory. What's the best way to do this in order to avoid making them do a "cd" over and over again in their sh'es? The dir() function does not work unfortunately (perhaps it only works in the jenkins jnlp container?) Ideally we could do something like this: ``` contatiner(name: 'mycontainer', dir: "/home/app/foo") { ... } ``` or... contatiner(name: 'mycontainer') { dir("/home/app/foo") { ... } } |
New:
We use the kubernetes plugin with enterprise jenkins. As soon as developers refer to one of their containers from their pod template, the first thing they usually want to do is to cd into a certain directory. What's the best way to do this in order to avoid making them do a "cd" over and over again in their sh'es? The dir() function does not work unfortunately (perhaps it only works in the jenkins jnlp container?) Ideally we could do something like this: {code:java} container(name: 'mycontainer', dir: "/home/app/foo") { ... } {code} or... {code:java} container(name: 'mycontainer') { dir("/home/app/foo") { ... } } {code} |
The problem is that the temporary files are created in the default container. This is clearly visible with such a pipeline
The output shows the /tmp/foo@tmp dir created in the default container rather than in the secondOne.
Looking a bit at the sources, it seems to me that the cause of the problem is that hudson.FilePath used in org.jenkinsci.plugins.workflow.steps.PushdStep holds information about the agent but not about the container causing org.jenkinsci.plugins.durabletask.BourneShellScript to create its temporary files at the wrong place and consequently not able to execute the script.