4646@ Component
4747public class CmdManagerImpl implements CmdManager {
4848
49+ private enum ShellType {
50+ Bash ,
51+
52+ PowerShell ;
53+ }
54+
4955 @ Autowired
5056 private SpringEventManager eventManager ;
5157
@@ -60,7 +66,8 @@ public CmdIn createShellCmd(Job job, Step step, NodeTree tree) {
6066 .setCondition (node .getCondition ())
6167 .setAllowFailure (node .isAllowFailure ())
6268 .setDockers (findDockerOptions (node ))
63- .setScripts (linkScript (node ))
69+ .setBash (linkScript (node , ShellType .Bash ))
70+ .setPwsh (linkScript (node , ShellType .PowerShell ))
6471 .setEnvFilters (linkFilters (node ))
6572 .setInputs (linkInputs (node ).merge (job .getContext (), false ))
6673 .setTimeout (job .getTimeout ());
@@ -125,17 +132,24 @@ private Set<String> linkFilters(StepNode current) {
125132 return output ;
126133 }
127134
128- private List <String > linkScript (StepNode current ) {
135+ private List <String > linkScript (StepNode current , ShellType shellType ) {
129136 List <String > output = new LinkedList <>();
130137
131138 if (current .hasParent ()) {
132139 Node parent = current .getParent ();
133140 if (parent instanceof StepNode ) {
134- output .addAll (linkScript ((StepNode ) parent ));
141+ output .addAll (linkScript ((StepNode ) parent , shellType ));
135142 }
136143 }
137144
138- output .add (current .getScript ());
145+ if (shellType == ShellType .Bash ) {
146+ output .add (current .getBash ());
147+ }
148+
149+ if (shellType == ShellType .PowerShell ) {
150+ output .add (current .getPwsh ());
151+ }
152+
139153 return output ;
140154 }
141155
@@ -161,7 +175,7 @@ private void setPlugin(String name, ShellIn cmd) {
161175 cmd .setPlugin (name );
162176 cmd .setAllowFailure (plugin .isAllowFailure ());
163177 cmd .addEnvFilters (plugin .getExports ());
164- cmd .addScript (plugin .getScript ());
178+ cmd .addBash (plugin .getScript ());
165179
166180 // apply docker from plugin as run time if it's specified
167181 ObjectsHelper .ifNotNull (plugin .getDocker (), (docker ) -> {
0 commit comments