jenkinsci/git-changelog-plugin

Since upgrading to 3.5 and then 3.7, the create file feature is not working.

Closed this issue · 1 comments

Version report

Jenkins and plugins versions report:

Jenkins: 2.289.1
OS: Windows Server 2016 - 10.0
---
ace-editor:1.1
ant:1.11
antisamy-markup-formatter:2.1
any-buildstep:0.1
apache-httpcomponents-client-4-api:4.5.13-1.0
backup:1.6.1
bootstrap4-api:4.6.0-3
bootstrap5-api:5.0.1-2
bouncycastle-api:2.20
build-timestamp:1.0.3
caffeine-api:2.9.1-23.v51c4e2c879c8
changes-since-last-success:0.6
checks-api:1.7.0
command-launcher:1.6
conditional-buildstep:1.4.1
credentials-binding:1.25
credentials:2.5
display-url-api:2.3.5
echarts-api:5.1.2-2
email-ext:2.83
envinject-api:1.7
envinject:2.4.0
external-monitor-job:1.7
flexible-publish:0.16.1
font-awesome-api:5.15.3-3
git-changelog:3.7
git-client:3.7.2
git:4.7.2
github-api:1.123
github:1.33.1
htmlpublisher:1.25
jackson2-api:2.12.3
javadoc:1.6
jdk-tool:1.5
join:1.21
jquery-detached:1.2.1
jquery3-api:3.6.0-1
jsch:0.1.55.2
junit:1.50
ldap:2.7
mailer:1.34
matrix-auth:2.6.7
matrix-project:1.19
maven-plugin:3.11
msbuild:1.30
mstest:1.0.0
nunit:0.27
okhttp-api:3.14.9
pam-auth:1.6
parameterized-trigger:2.41
plain-credentials:1.7
plugin-util-api:2.3.0
popper-api:1.16.1-2
popper2-api:2.5.4-2
postbuildscript:2.11.0
run-condition:1.5
scm-api:2.6.4
script-security:1.77
seleniumhtmlreport:1.0
simple-queue:1.4.1
snakeyaml-api:1.29.1
ssh-credentials:1.19
sshd:3.0.3
structs:1.23
synopsys-coverity:2.4.1
test-results-analyzer:0.3.5
testng-plugin:1.15
thinBackup:1.10
token-macro:2.15
trilead-api:1.0.13
windows-slaves:1.8
workflow-api:2.44
workflow-cps:2.92
workflow-job:2.41
workflow-scm-step:2.12
workflow-step-api:2.23
workflow-support:3.8```

- What Operating System are you using (both controller, and any agents involved in the problem)?

PS C:\Users\Administrator.WIN-1Q8BGQHN6SP> [System.Environment]::OSVersion.Version

Major Minor Build Revision


10 0 14393 0

IE: WIndows Server 2016 64-bit


### Reproduction steps

<!--
- Write bullet-point reproduction steps.
- Be explicit about any relevant configuration, jobs, build history, user accounts, etc., redacting confidential information as needed.
- The best reproduction steps start with a clean Jenkins install, perhaps a `docker run` command if possible.
- Use screenshots where appropriate, copy textual output otherwise. When in doubt, do both.
- Include relevant logs, debug if needed - https://www.jenkins.io/doc/book/system-administration/viewing-logs/
-->

1. Create Freestyle project
2. Source Code Management
    1. Git
        1. Repository:   Choose your favorite repository
        2. Credentials:  Supply your credentials to your git repository
        3. Branches to build:   */develop       == in my case it is develop
3. Post-build Actions
    1. Git-changelog
        1. Choose from reference:   First commit in repo
        2. Choose 'to' reference:   develop    == in my case it is develop
        3. Pattern:  ^\[maven-release-plugin\].*|^\[Gradle Release Plugin\].*
        4. Create file:  check the box
            1. Filename:   CHANGELOG.html   ====   If stop here, you get first case below.
            2. Check "Use a template file from workspace" and enter:   CHANGELOGPlate.txt  
            3. Make sure file CHANGELOGPlate.txt exists in the workspace directory with the content:
                ```
                <h1> Git Changelog for branch "BRANCHNAME" </h1>  

                {{#commits}}
                {{#merge}}
                  <hr>
                  {{commitTime}} - <font size="+2"><b>{{{messageTitle}}}</b></font><br/>
                  <p>MERGEDESCRIPTION</p>
                {{/merge}}
                {{/commits}}
                ```  
                == This will give case 2 below.
            4. Uncheck the "Use a template file from workspace" box
            5. Check the "Configure template here" box instead.
            6. Enter the content of the CHANGELOGPLATE.txt file above.   ===   This actually works.

### Results

Expected result:

As given if all steps to 3.4.6 is applied above.
---
--- Git Changelog ---
---
Creating changelog CHANGELOG.html
Notifying upstream projects of job completion
Finished: SUCCESS

Actual result:
Case 1 if 3.4.1 is applied:   IE:  Only create file is checked.
---
--- Git Changelog ---
---
Creating changelog CHANGELOG.htmljava.lang.RuntimeException: changelog.mustache
	at se.bjurr.gitchangelog.api.GitChangelogApi.getTemplateString(GitChangelogApi.java:149)
	at se.bjurr.gitchangelog.api.GitChangelogApi.render(GitChangelogApi.java:104)
	at se.bjurr.gitchangelog.api.GitChangelogApi.render(GitChangelogApi.java:164)
	at org.jenkinsci.plugins.gitchangelog.perform.RemoteCallable.call(RemoteCallable.java:168)
	at org.jenkinsci.plugins.gitchangelog.perform.RemoteCallable.call(RemoteCallable.java:27)
	at hudson.FilePath.act(FilePath.java:1252)
	at org.jenkinsci.plugins.gitchangelog.perform.GitChangelogPerformer.performerPerform(GitChangelogPerformer.java:37)
	at org.jenkinsci.plugins.gitchangelog.GitChangelogRecorder.perform(GitChangelogRecorder.java:50)
	at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:80)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:752)
	at hudson.model.Build$BuildExecution.post2(Build.java:177)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:697)
	at hudson.model.Run.execute(Run.java:1931)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
Caused by: java.io.FileNotFoundException: Was unable to find file, or resouce, "changelog.mustache"
	at se.bjurr.gitchangelog.api.GitChangelogApi.getTemplateString(GitChangelogApi.java:142)
	... 18 more

Case 2 if 3.4.4 is applied above.   IE:  Using a template file.
---
--- Git Changelog ---
---
Creating changelog CHANGELOG.htmljava.lang.NullPointerException: The input is required.
	at com.github.jknack.handlebars.internal.lang3.Validate.notNull(Validate.java:225)
	at com.github.jknack.handlebars.Handlebars.compileInline(Handlebars.java:471)
	at com.github.jknack.handlebars.Handlebars.compileInline(Handlebars.java:453)
	at se.bjurr.gitchangelog.api.GitChangelogApi.render(GitChangelogApi.java:106)
	at se.bjurr.gitchangelog.api.GitChangelogApi.render(GitChangelogApi.java:164)
	at org.jenkinsci.plugins.gitchangelog.perform.RemoteCallable.call(RemoteCallable.java:168)
	at org.jenkinsci.plugins.gitchangelog.perform.RemoteCallable.call(RemoteCallable.java:27)
	at hudson.FilePath.act(FilePath.java:1252)
	at org.jenkinsci.plugins.gitchangelog.perform.GitChangelogPerformer.performerPerform(GitChangelogPerformer.java:37)
	at org.jenkinsci.plugins.gitchangelog.GitChangelogRecorder.perform(GitChangelogRecorder.java:50)
	at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:80)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:752)
	at hudson.model.Build$BuildExecution.post2(Build.java:177)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:697)
	at hudson.model.Run.execute(Run.java:1931)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)



NOTE:   This was all working prior to upgrade to version 3.5

WORKAROUND:    Put the template directly into the job as per 3.4.6 above.

should be fixed now. Open issue again if not working.