-
Bug
-
Resolution: Unresolved
-
Minor
-
None
Hi,
When using a scripted Pipeline with a node, there is no workspace directory created until you use a Jenkins built-in step which needs to write something.
If you use plain Groovy code which write something, the workspace doesn't get created.
The following simple Pipeline proves the bug:
import groovy.json.JsonBuilder node { def token = [APPS: [ [id: 1, app_name: "${APP_NAME}", version: "${APP_VERSION}"] ]] stage('Cleaning workspce') { cleanWs() } stage('Generating the token') { new File("${WORKSPACE}/mep.token").write(new JsonBuilder(token).toPrettyString()) } }
java.io.FileNotFoundException: /var/lib/jenkins/workspace/foobar/mep.token (Aucun fichier ou dossier de ce type)
I'm not sure if it's a bug or if the documentation is wrong, but to me, it's a bug.
Stating the documentation:
A workspace is automatically allocated for you with the node step