简体   繁体   English

从Java将值传递给Jenkins

[英]Passing values to Jenkins from Java

Is there any way to pass value from Java (maven project) code to Jenkins job?. 有什么方法可以将Java (Maven项目)代码中的值传递给Jenkins作业?

Suppose that my java code looks like below. 假设我的Java代码如下所示。

public void generateRandom(){
    double random = Math.random();
    return random;
}

One of my Jenkins job in the pipeline will execute above code and the value returned by the code needs to be passed to a downstream job. 我在管道中的Jenkins作业之一将执行上述代码,并且该代码返回的值需要传递给下游作业。 The downstream job is parameterized. 下游作业已参数化。

Is it possible to pass the generated random number to the downstream job somehow like this - 是否可以将生成的随机数以某种方式传递给下游作业-

${random}

You will have to use a property read operation said like here https://jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#readproperties-read-properties-from-files-in-the-workspace-or-text . 您将必须使用这样的属性读取操作: https://jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#readproperties-read-properties-from-files-in-the-workspace-or或-text

May be you can write the output of java code to some file, and make that input for the next jenkins job.? 也许您可以将Java代码的输出写入某个文件,然后将该输入用于下一个jenkins作业。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM