How does the `container()` step work?
IntermediateConceptPlugins, JCasC & Jenkins on Kubernetes
Answer
All containers in an agent pod share the workspace volume (/home/jenkins/agent). container('kaniko') { sh '...' } runs the shell step inside that container through the Kubernetes exec API, with the same working directory. So one stage can run npm test in node, then the build in kaniko, then the scan in trivy, all on the same files without stashing. The container image needs a shell (/bin/sh) for sh steps; distroless images do not have one, which is why tools ship :debug variants.
More on Plugins, JCasC & Jenkins on Kubernetes
How do you manage plugins in a reproducible way?IntermediateWhat does `jenkins-plugin-cli` resolve for you, and what flags matter?IntermediateWhy should you keep the number of plugins low?BeginnerWhat is JCasC and how is it loaded?BeginnerWhat are the top-level root elements in a JCasC file?IntermediateHow do you inject secrets into JCasC without committing them?Advanced