LoginSignup
2
0

More than 3 years have passed since last update.

Jenkins PipelineでSlave PC側のファイル内容を読みこむ

Last updated at Posted at 2019-08-27

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ファイルとかもいけますので、お試しあれー。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0