Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide GIT_COMMIT_TITLE as environment variable #1074

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

raghavgarg098
Copy link
Contributor

@raghavgarg098 raghavgarg098 commented Apr 17, 2021

JENKINS-52490 - Provide GIT_COMMIT_TITLE as environment variable

Updated the pull request by Jeff Krunek . Fixed the test case testCommitMessageisEnvVar to directly run the freestyle job so the checkout step is automatically initiated and setting up the GIT_COMMIT_TITLE environment variable in the buildEnvironment API instead of the checkout step.

Checklist

  • I have read the CONTRIBUTING doc
  • I have referenced the Jira issue related to my changes in one or more commit messages
  • I have added tests that verify my changes
  • Unit tests pass locally with my changes
  • I have added documentation as necessary
  • No Javadoc warnings were introduced with my changes
  • No spotbugs warnings were introduced with my changes
  • Online help has been added and reviewed for any new or modified fields
  • I have interactively tested my changes
  • Any dependent changes have been merged and published in upstream modules (like git-client-plugin)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Further Comments

As CaptureEnvironmentBuilder does not capture the environment variable GIT_COMMIT_TITLE if populated in the checkout step. Other variables like GIT_BRANCH and GIT_COMMIT are captured by the CaptureEnvironmentBuilder as they are populated in the buildEnvironment API as well, but GIT_COMMIT_TITLE can not be populated so implemented it in buildEnvironment API.

@raghavgarg098 raghavgarg098 changed the title Provide GIT_COMMIT_TITLE Provide GIT_COMMIT_TITLE as environment variable Apr 20, 2021
@MarkEWaite MarkEWaite self-requested a review April 21, 2021 17:07
@github-actions github-actions bot added the dependencies Dependency related change label May 6, 2023
@dengliming
Copy link

I wonder when this pr can be merged, it's been a long time...

@MarkEWaite MarkEWaite removed the dependencies Dependency related change label Apr 7, 2024
@jtnord
Copy link
Member

jtnord commented Apr 8, 2024

I would recommend caution here - as per the ant /maven / multiple levels inside pipeline plugin and many other places where untrusted data has made its way into environment variables and then escaping it becomes a necessity for anyone wishing to consume it. (maven/ant PR titles for example in the scm-api, esp when any safeness needs to be multi level of scripts).

if this is needed then it would seem beneficial to those that want this to obtain it directly the checkout themselves (git log -1 --format=format:%s HEAD) and not from the environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants