简体   繁体   English

sed shell 和 jenkins 部署

[英]sed shell with jenkins deployment

I'm working on something at the moment and just now I even wonder if what I am working on is even possible.我现在正在做一些事情,而现在我什至想知道我正在做的事情是否可能。

I want to SSH from jenkins to a shell script and use variables form a rc file that are in a git Repository.我想 SSH 从 jenkins 到 shell 脚本并使用变量形成一个 rc 文件,该文件位于 ZBA9F111ECC3429BD6D1E953B933FDC (The Shell script and rc file are in the same repo) (Shell 脚本和 rc 文件在同一个仓库中)

Nothing that I tried works and now I'm starting to wondering if it's even possible.我尝试过的任何方法都不起作用,现在我开始怀疑它是否可能。

Here's is my local script but i get the same output on jenkins.这是我的本地脚本,但我在 jenkins 上得到相同的 output。

docker exec -it test-container bash 'sed -f <(printf "s/${DOMAIN}\.%s/www.&.${DOMAIN_SUFFIX_STAGE}/g\n" ${LANG_KEYS}) /var/www/foo/sed/test.txt > /var/www/foo/sed/new-2.txt'

No matter what I do I get this error无论我做什么,我都会收到此错误

bash: sed -f <(printf "s/${DOMAIN}\.%s/www.&.${DOMAIN_SUFFIX_STAGE}/g\n" ${LANG_KEYS}) /var/www/foo/sed/test.txt > /var/www/foo/sed/new-2.txt: No such file or directory

And yes I can confirm that the directory is there是的,我可以确认目录在那里

Here's an easier way to reproduce your problem:这是重现问题的更简单方法:

$ bash "echo Hello"
bash: echo Hello: No such file or directory

This happens because the expected syntax is bash yourfile .发生这种情况是因为预期的语法是bash yourfile The string you are passing is not a useful filename, so it fails.您传递的字符串不是有用的文件名,因此它失败了。

To run a string argument as a command, you can use bash -c commandstring :要将字符串参数作为命令运行,您可以使用bash -c commandstring

$ bash -c "echo Hello"
Hello

This makes bash interpret the parameter as a shell command to execute, instead of a filename to open.这使得 bash 将参数解释为要执行的 shell 命令,而不是要打开的文件名。

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

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