をキャプチャ:Jenkinsfile宣言パイプライン - 私のような始まるJenkinsfileを書いて、すべてのチェックアウトSCM出力
pipeline {
agent {
label 'ec2-slave'
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
...
私はgitの関連を使用する必要があるので、私はcheckout scm
コールの出力をキャプチャしたいと思います次のステップの情報。
もちろん、このステップは、このような出力を生成し、見事に動作します:
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url xxxxxxxxx # timeout=10
Fetching upstream changes from xxxxxxxxx
> git --version # timeout=10
using GIT_SSH to set credentials jenkins ssh key
> git fetch --tags --progress xxxxxxxxx +refs/heads/*:refs/remotes/origin/*
Seen branch in repository origin/master
Seen 2 remote branches
> git tag -l # timeout=10
Checking out Revision 10214b72d4c1f2c69444cc79a1af7ecc7f033349 (origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 10214b72d4c1f2c69444cc79a1af7ecc7f033349
> git rev-list 10214b72d4c1f2c69444cc79a1af7ecc7f033349 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Checkout)
[Pipeline] checkout
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url xxxxxxxxx # timeout=10
Fetching upstream changes from xxxxxxxxx
> git --version # timeout=10
using GIT_SSH to set credentials jenkins ssh key
> git fetch --tags --progress xxxxxxxxx +refs/heads/*:refs/remotes/origin/*
Seen branch in repository origin/master
Seen 2 remote branches
> git tag -l # timeout=10
Checking out Revision 10214b72d4c1f2c69444cc79a1af7ecc7f033349 (origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 10214b72d4c1f2c69444cc79a1af7ecc7f033349
は、キャプチャおよび/または前のパイプラインステップを参照の意図する方法はありますか?
私はこのJenkinsfileをフリースタイルの構文から変換しています。私は、変数に 'sh'呼び出しを保存することで、前のステップを"参照 "することができました。 'checkout scm'を使って同じことを達成する方法がわかりません...単純な解決策だと確信していますが、GroovyとJenkinsfilesについてまだよく学んでいます – asdoylejr
私は' script {} 'ブロックでこれを試してみましたが、これは奇妙な出力を生成しています: 'checkout scm' ' echo "$ {scm.dump()}" ' これは私のためにあまり役に立たない' null'値の束を持つマップを生成します。 – asdoylejr