pipeline step description

 pipeline 有很多提供step的插件, 如 SCM step提供了sh, git操作等step操作

utility step 插件提供了文件读写压缩等step

此处对scm step sh label功能进行介绍

修改前:

    echo 'Hello World'

给step添加label:

f方式一:sh script: " echo 'Hello World'", label: "tet it"

方式二:sh returnStdout: true ,script: "echo hello", label: "aaa"

方式三:sh(script: "echo hi", returnStdout: true, label: "hixx")

添加后多了一个字段: "parameterDescription", 这个字段保存了执行的命令

https://www.e-learn.cn/topic/3024674

https://github.com/jenkinsci/pipeline-stage-view-plugin/tree/master/rest-api#get-jobjob-namewfapiruns

方式四: 使用labelled-step插件: https://www.jenkins.io/doc/pipeline/steps/labelled-steps/

https://plugins.jenkins.io/labelled-steps/

附比对:

添加label前:

{
"_links": {
"self": {
"href": "/job/te_pipeline/3/execution/node/11/wfapi/describe"
}
},
"id": "11",
"name": "test",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1625238851132,
"durationMillis": 4270,
"pauseDurationMillis": 0,
"stageFlowNodes": [{
"_links": {
"self": {
"href": "/job/te_pipeline/3/execution/node/12/wfapi/describe"
},
"log": {
"href": "/job/te_pipeline/3/execution/node/12/wfapi/log"
},
"console": {
"href": "/job/te_pipeline/3/execution/node/12/log"
}
},
"id": "12",
"name": "Shell Script",
"execNode": "",
"status": "SUCCESS",
"parameterDescription": " echo 'Hello World'",
"startTimeMillis": 1625238852265,
"durationMillis": 3060,
"pauseDurationMillis": 0,
"parentNodes": ["11"]
}]
}

添加 label 后

{
"_links": {
"self": {
"href": "/job/te_pipeline/5/execution/node/11/wfapi/describe"
}
},
"id": "11",
"name": "test",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1625240102435,
"durationMillis": 784,
"pauseDurationMillis": 0,
"stageFlowNodes": [{
"_links": {
"self": {
"href": "/job/te_pipeline/5/execution/node/12/wfapi/describe"
},
"log": {
"href": "/job/te_pipeline/5/execution/node/12/wfapi/log"
},
"console": {
"href": "/job/te_pipeline/5/execution/node/12/log"
}
},
"id": "12",
"name": "tet it",
"execNode": "",
"status": "SUCCESS",
"parameterDescription": " echo 'Hello World'",
"startTimeMillis": 1625240102561,
"durationMillis": 625,
"pauseDurationMillis": 0,
"parentNodes": ["11"]
}]
}

原文地址:https://www.cnblogs.com/i-shu/p/14965317.html