admin管理员组文章数量:1414887
I am using a customized Groovy shared library in my Jenkinsfile.
during the Jenkinsfile I have this Groovy commands array list:
commands = [
"pwd",
"ls -la",
"some predefined groovy closure",
"cd /tmp",
"some predefined groovy closure2",
"pwd",
"ls -la"
]
I want to execute the Shell commands in the same Shell so I have the context from previous commands, but also execute the commands and closures in the order they appear in the 'commands' array list.
It'll be best if all the commands and closures will be executed in the same shell. But first step is to make all shell commands run in the same shell.
I also want the output from the commands to be printed to my Jenkins build logs right after execution (live output will be best).
I tried using screen
to create a new Shell screen and execute the Shell commands on it, but I run my Jenkins as a master OS4 pod, and the workers as dynamic pods that run as builds are triggered, so I don't actually have a terminal, which made the screen commands fail.
This is an example of a stage in my pipeline that uses:
def ansibleTowerPlugin = {
ansibleTower (
//////plugin configuration
)
}
genStage(
title: "deploy with awx",
containerName: "example"
commands: [
'pwd',
'ls -la',
ansibleTowerPlugin,
'cd ./example_dir',
{
sh "echo testing" //testing closure
},
'pwd',
'ls -la'
]
)
],
[
costumeContainerTemplates: [
name: "example"
image: "artifctory/example/image:tag"
alwaysPullImage: "true"
]
)
I used to execute the shell commands like this (before I added the closures):
sh argsmands.join(" && ")
but this does not work with the closures.
Would love some help if anyone has an idea
本文标签: jenkinsexecute Shell commands in the same Shell non sequentiallyStack Overflow
版权声明:本文标题:jenkins - execute Shell commands in the same Shell non sequentially - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745154316a2645075.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论