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

JENKINS-65892 Support macro tokens in github context label #14

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

Conversation

gjabouley-invn
Copy link

This is another attempt to address JENKINS-65892.

Initial change is in #5, credits to @akomakom.

As i did not know how to rebase @akomakom repo, i just cherry-picked its change over the latest master of main repo.

Note that although change is quite simple, i was not able to test the feature, as i don't have a testing environnement available which includes a working GitHub setup...

Submitter checklist

@gjabouley-invn
Copy link
Author

Was able to test it today, tokens are properly replaced 👍

Following output will show twice in build log, not sure it is worth printing actually:
Github Custom Notification Context: Expanded token macro from 'jenkins/${JOB_BASE_NAME}' to 'jenkins/feature%2Ftest_check'

In case of error (variable does not exist), the following is printed in build log:

Github Custom Notification Context: Unable to expand GitHub Notification context macro 'jenkins/${BERFEZGESZ}'ERROR: Github Custom Notification Context: Unable to expand GitHub Notification context macro 'jenkins/${BERFEZGESZ}'
org.jenkinsci.plugins.tokenmacro.MacroEvaluationException: Error processing tokens
	at org.jenkinsci.plugins.tokenmacro.Parser.parse(Parser.java:97)
	at org.jenkinsci.plugins.tokenmacro.Parser.process(Parser.java:75)
	at org.jenkinsci.plugins.tokenmacro.Parser.process(Parser.java:68)
	at org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:196)
	at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:234)
	at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:204)
	at org.jenkinsci.plugins.githubScmTraitNotificationContext.NotificationContextTrait$CustomContextNotificationStrategy.buildContext(NotificationContextTrait.java:127)
	at org.jenkinsci.plugins.githubScmTraitNotificationContext.NotificationContextTrait$CustomContextNotificationStrategy.buildNotification(NotificationContextTrait.java:161)
	at org.jenkinsci.plugins.githubScmTraitNotificationContext.NotificationContextTrait$CustomContextNotificationStrategy.notifications(NotificationContextTrait.java:180)
	at org.jenkinsci.plugins.github_branch_source.GitHubBuildStatusNotification.createBuildCommitStatus(GitHubBuildStatusNotification.java:92)
	at org.jenkinsci.plugins.github_branch_source.GitHubBuildStatusNotification$JobCompletedListener.onCompleted(GitHubBuildStatusNotification.java:333)
	at hudson.model.listeners.RunListener.lambda$fireCompleted$0(RunListener.java:207)
	at jenkins.util.Listeners.lambda$notify$0(Listeners.java:59)
	at jenkins.util.Listeners.notify(Listeners.java:67)
	at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:205)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun.finish(WorkflowRun.java:645)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:1068)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:1500)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$3.run(CpsThreadGroup.java:512)
	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:41)
	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
	at jenkins.util.ErrorLoggingExecutorService.lambda$wrap$0(ErrorLoggingExecutorService.java:51)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.jenkinsci.plugins.tokenmacro.MacroEvaluationException: Unrecognized macro 'BERFEZGESZ' in 'jenkins/${BERFEZGESZ}'
	at org.jenkinsci.plugins.tokenmacro.Parser.processToken(Parser.java:492)
	at org.jenkinsci.plugins.tokenmacro.Parser.parseDelimitedToken(Parser.java:178)
	at org.jenkinsci.plugins.tokenmacro.Parser.parseToken(Parser.java:111)
	at org.jenkinsci.plugins.tokenmacro.Parser.parse(Parser.java:87)
	... 28 more

and a commit check with raw string is created:
image

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.

1 participant