Skip to content

Commit

Permalink
Merge pull request #18 from nekoimi/master
Browse files Browse the repository at this point in the history
消息文本添加环境变量支持
  • Loading branch information
nekoimi committed May 23, 2023
2 parents 9fcaa10 + 4d2d413 commit fb62aa3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<revision>1.0.1</revision>
<changelist>999999-SNAPSHOT</changelist>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.version>2.332.4</jenkins.version>
<jenkins.version>2.324</jenkins.version>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void setImageUrl(String imageUrl) {
public void perform(
@NonNull Run<?, ?> run,
@NonNull FilePath workspace,
@NonNull EnvVars env,
@NonNull EnvVars envVars,
@NonNull Launcher launcher,
@NonNull TaskListener listener) throws InterruptedException, IOException {
RobotProperty property = WXWorkGlobalConfig.instance().getRobotPropertyById(robot);
Expand All @@ -134,9 +134,9 @@ public void perform(
}
RunUser runUser = JenkinsUtils.getRunUser(run, listener);
RobotPipelineVars pipelineVars = RobotPipelineVars.builder()
.robot(this.robot).type(this.type).atMe(this.atMe).atAll(this.atAll)
.at(this.at).text(this.text).imageUrl(this.imageUrl).runUser(runUser)
.env(env).workspace(workspace).listener(listener).build();
.robot(envVars.expand(this.robot)).type(this.type).atMe(this.atMe).atAll(this.atAll)
.at(this.at).text(this.text).imageUrl(envVars.expand(this.imageUrl)).runUser(runUser)
.envVars(envVars).workspace(workspace).listener(listener).build();
RobotRequest robotRequest = RobotMessageFactory.makeRobotRequest(pipelineVars);
if (robotRequest == null) {
listener.error("不支持的消息!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class RobotPipelineVars {
/**
* 环境变量
*/
private EnvVars env;
private EnvVars envVars;

/**
* workspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public RobotRequest transferRobotRequest(RobotPipelineVars pipelineVars) {
MarkdownMessage.Builder builder = MarkdownMessage.builder();
List<String> textList = pipelineVars.getText();
List<String> textCollect = textList.stream().filter(StrUtils::isNotBlank).collect(Collectors.toList());
builder.content(String.join("\n", textCollect));
builder.content(pipelineVars.getEnvVars().expand(String.join("\n", textCollect)));
return builder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public RobotRequest transferRobotRequest(RobotPipelineVars pipelineVars) {
List<String> textList = pipelineVars.getText();
List<String> textCollect =
textList.stream().filter(Objects::nonNull).filter(StrUtils::isNotBlank).collect(Collectors.toList());
builder.content(String.join("\n", textCollect));
builder.content(pipelineVars.getEnvVars().expand(String.join("\n", textCollect)));
return builder.build();
}
}

0 comments on commit fb62aa3

Please sign in to comment.