-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from atanasenko/env_params_folding
[scmsource] Allow queue item folding to happen
- Loading branch information
Showing
2 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...main/java/com/github/kostyasha/github/integration/multibranch/GitHubParametersAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.github.kostyasha.github.integration.multibranch; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import hudson.EnvVars; | ||
import hudson.Extension; | ||
import hudson.model.Action; | ||
import hudson.model.EnvironmentContributor; | ||
import hudson.model.InvisibleAction; | ||
import hudson.model.ParameterValue; | ||
import hudson.model.ParametersAction; | ||
import hudson.model.Run; | ||
import hudson.model.TaskListener; | ||
import hudson.model.Queue.Item; | ||
import hudson.model.Queue.Task; | ||
import hudson.model.queue.FoldableAction; | ||
|
||
/** | ||
* Simpler replacement for {@link ParametersAction} that does not stand in the way of 'folding' queue items | ||
* @author atanasenko | ||
* | ||
*/ | ||
public class GitHubParametersAction extends InvisibleAction implements FoldableAction { | ||
|
||
private List<ParameterValue> params; | ||
|
||
public GitHubParametersAction(List<ParameterValue> params) { | ||
this.params = params; | ||
} | ||
|
||
@Override | ||
public void foldIntoExisting(Item item, Task owner, List<Action> actions) { | ||
item.addOrReplaceAction(this); | ||
} | ||
|
||
@Extension | ||
public static class GitHubEnvContributor extends EnvironmentContributor { | ||
@Override | ||
public void buildEnvironmentFor(Run r, EnvVars envs, TaskListener listener) throws IOException, InterruptedException { | ||
GitHubParametersAction action = r.getAction(GitHubParametersAction.class); | ||
if (action == null) { | ||
return; | ||
} | ||
action.params.forEach(p -> p.buildEnvironment(r, envs)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters