jenkinsci / docker-plugin

Jenkins cloud plugin that uses Docker
https://plugins.jenkins.io/docker-plugin/
MIT License
486 stars 322 forks source link

Add Instance Number to Environment Variables #1070

Open rakstar opened 2 months ago

rakstar commented 2 months ago

I run multiple builds on a single host by setting "Instance Capacity" > 1. While this works fine, I have a monolithic app that takes a while to do a fresh git clone with each build. I could speed this up by bind mounting my "Remote File System Root" to a volume so that previous git clones can be reused but, as far as I can tell, this currently wouldn't work properly with multiple concurrent instances.

I think I could address this by having a volume mount declaration like: type=volume,src=jenkinsagent,dst=/home/jenkins/agent$INSTANCE_NUMBER

OR perhaps by having a static volume mount and setting my Remote File System Root to something like: /home/jenkins/agent/workspace_$INSTANCE_NUMBER

But for the above to work, I believe the return value of the following method needs to be saved to the INSTANCE_NUMBER environment variable:

https://github.com/jenkinsci/docker-plugin/blob/ae073a3dd095ab4dc1331d64b169101b125b42cf/src/main/java/com/nirima/jenkins/plugins/docker/DockerCloud.java#L341