I have an upstream freestyle job and a downstream pipeline job.
The freestyle job is triggered via a Bitbucket hook to run whenever code is pushed to Bitbucket.
The freestyle job should capture the commit SHA and branch name and pass both to the pipeline job. It also generates a variable based on the branch author, that should also be passed.
In the freestyle job I do something like the following, which works and echos the expected parameters.
cd $WORKSPACE/prancer/ GIT_AUTHOR=$(git show --format="%an" | head -1) echo '-------------' echo 'git_commit is '$GIT_COMMIT echo 'git_branch is '$GIT_BRANCH echo 'git_author is '$GIT_AUTHOR echo '-------------'
I have the job configured to kick off the pipeline job like so;
Downstream, the pipeline job echos the
GIT_BRANCH as expected. However, the
GIT_AUTHOR just echos the variable name, not a value.
Somehow, the git commit and branch are being passed along, but the generated variable git_author isn't. I tried piping the author to a file, archiving it in the freestyle job and using the additional
Parameters from properties file step, but that still isn't passing to the pipeline job.
I can confirm that
- GIT_AUTHOR has a value in the freestyle job
- If I save GIT_AUTHOR to a properties file, I can view the file (with the author inside!) in the workspace of the freestyle job
- The pipeline job isn't receiving the value, just the actual string
$GIT_AUTHOR. If I check the parameters page for the triggered pipeline build commit and branch have values, author is the string
How do I use a generated variable's value from an upstream freestyle job when building a downstream pipeline job?