Jenkins PipelineでSlave PC側のファイル内容を読みこむ
Jenkins Pipelineを使って、Slave PCの成果物の一部から、内容を引っぱりたいというニッチな問題。
普通にGroovyで引っ張ろうとすると、Jenkins側のMaster PCのパスを引っぱってきてしまうので、一工夫します。
jenkinsfile.groovy
//returnStdout: trueとすると、echoの実行結果がreturnされる
def CONTENTS = bat returnStdout: true, script: '@echo off && for /f "delims=" %%a in ( contents.txt ) do ( echo %%a )'
echoは必ずOFFにしないと、実行コードまで引っ張ってきてしまいますのでご注意ください。
これで、テキストの戻り値を見れば引っぱれます。一応複数行も対応したコードにはなっています。
htmlファイルとかもいけますので、お試しあれー。
Author And Source
この問題について(Jenkins PipelineでSlave PC側のファイル内容を読みこむ), 我々は、より多くの情報をここで見つけました https://qiita.com/kr_ss/items/b852ab51021df2e681ef著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .