Skip to content

Commit

Permalink
Improved usage of MissingContextVariableException
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Jan 19, 2024
1 parent 2b19db7 commit 451c815
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- TODO until in BOM: -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>655.v6e098b_87b_84f</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<classifier>tests</classifier>
<version>655.v6e098b_87b_84f</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
Expand All @@ -70,7 +82,6 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>655.v6e098b_87b_84f</version> <!-- TODO: Removes once the plugin is updated in the BOM -->
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void doStart() throws Exception {
for (MultiBinding<?> binding : step.bindings) {
if (binding.getDescriptor().requiresWorkspace() &&
(workspace == null || launcher == null)) {
throw new MissingContextVariableException(FilePath.class);
throw new MissingContextVariableException(FilePath.class, step.getDescriptor());
}
MultiBinding.MultiEnvironment environment = binding.bind(run, workspace, launcher, listener);
unbinders.add(environment.getUnbinder());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public void widerRequiredContext() throws Throwable {
WorkflowRun b = r.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0));
r.assertLogNotContains("We should fail before getting here", b);
r.assertLogContains("Required context class hudson.FilePath is missing", b);
r.assertLogContains("Perhaps you forgot to surround the step with a step that provides this, such as: node", b);
r.assertLogContains("Perhaps you forgot to surround the withCredentials step with a step that provides this, such as: node", b);
});
}

Expand Down

0 comments on commit 451c815

Please sign in to comment.