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

Unique Names for Regex Patterns #27

Merged
merged 11 commits into from
May 16, 2022
Merged

Unique Names for Regex Patterns #27

merged 11 commits into from
May 16, 2022

Conversation

pyieh
Copy link
Contributor

@pyieh pyieh commented Apr 15, 2022

Added a Name field to regex patterns as part of the global configurations and forces them to be unique. Allows for human-readable label of regex patterns and makes Admin remote configuration of these patterns easier.

  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@pyieh pyieh requested a review from timja April 20, 2022 22:54
Copy link

@ramapalani ramapalani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pyieh pyieh merged commit e382f25 into jenkinsci:master May 16, 2022
@pyieh
Copy link
Contributor Author

pyieh commented May 17, 2022

@oleg-nenashev I'm wondering why the maven-release-plugin didn't cut a new release for the plugin (I had to manually do a release). Looks like there was an error message where the plugin's JAR is missing. Can you take a look and let me know what's missing and needs to be done?

@pyieh
Copy link
Contributor Author

pyieh commented May 24, 2022

@oleg-nenashev Can we get some help looking into why the maven-release-plugin didn't catch this PR's merge to master and release the plugin like other PR merges? And is there a way to force this?

@pyieh
Copy link
Contributor Author

pyieh commented May 25, 2022

@jglick Wondering if we can get some help looking into why the maven-release-plugin didn't catch and do a release for our PR merge and is there a way to force that?

@jglick
Copy link
Member

jglick commented May 26, 2022

why the maven-release-plugin didn't cut a new release for the plugin (I had to manually do a release)

Not sure I follow the question. Are you asking about https://www.jenkins.io/doc/developer/publishing/releasing-cd/ which you have not set up for this plugin? Human-oriented version numbers (1.3 etc.) produced manually and on demand via maven-release-plugin (running mvn -B release:prepare release:perform using personal Artifactory & GitHub credentials) is the traditional way of releasing plugins. Maybe you are asking something unrelated.

an error message where the plugin's JAR is missing

Which error message?

Better to use the dev list, and be specific.

@Faheetah
Copy link

This PR broke the plugin functionality, even using the snippet generator from Jenkins throws java.lang.ClassCastException: java.util.Collections$UnmodifiableMap cannot be cast to java.lang.String

@pyieh
Copy link
Contributor Author

pyieh commented Aug 17, 2022

@Faheetah Can you open a ticket with your specific Jenkins configs? We've been running this version in our production Jenkins since its release with no issues.

@Faheetah
Copy link

@pyieh someone already has one looks like, but no response to it. Do you have a config publicly viewable somewhere maybe the pipeline builder is wrong but I can't figure out how to make it work. Anyway this can move to the issue, I don't have it off hand but it's one of the most recently created

@v1v
Copy link
Member

v1v commented Aug 18, 2022

I've just found this is a breaking change, with 3.1 the below snippet worked like a charm

wrap([$class: 'MaskPasswordsBuildWrapper', varMaskRegexes: [[regex: 'token:[^,]*']]]) {
  // ...
}

but after upgrading to 3.3, things start failing apart:

15:39:59  [ERROR] Exception: java.lang.IllegalArgumentException: Could not instantiate {delegate={$class=MaskPasswordsBuildWrapper, varMaskRegexes=[{regex=token:[^,]*}]}} for org.jenkinsci.plugins.workflow.steps.CoreWrapperStep: java.lang.IllegalArgumentException: Could not instantiate {varMaskRegexes=[{regex=token:[^,]*}]} for com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper: java.lang.IllegalArgumentException: Could not instantiate {name=null, value=null} for com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsConfig$VarMaskRegexEntry: java.lang.ClassCastException: com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsConfig$VarMaskRegexEntry.value expects class java.lang.String but received class com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper$VarMaskRegex
15:39:59  [Pipeline] error

See this log

And the shared library step -> https://github.com/elastic/apm-pipeline-library/blob/a160e7fff39c0b0368cf63383b86629975ee1905/vars/githubAppToken.groovy#L87

@v1v
Copy link
Member

v1v commented Aug 18, 2022

If I use the new syntax from the Pipeline syntax:

maskPasswords(varMaskRegexes: [[name: null, value: [$class: 'VarMaskRegex', regex: 'token:[^,]*']]]) {
    // some block
}

image

It fails with the below stacktrace

16:22:53  ERROR: There were some failures with the notifications
16:22:53  java.lang.ClassCastException: java.util.Collections$UnmodifiableMap cannot be cast to java.lang.String
16:22:53  	at com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsConfig$VarMaskRegexEntry$DescriptorImpl.customInstantiate(MaskPasswordsConfig.java:731)
16:22:53  	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:304)
16:22:53  	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:474)
16:22:53  	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerceList(DescribableModel.java:585)
16:22:53  	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:458)
16:22:53  	at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:409)
16:22:53  	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:329)
16:22:53  Caused: java.lang.IllegalArgumentException: Could not instantiate {varMaskRegexes=[{name=null, value={$class=VarMaskRegex, regex=token:[^,]*}}]} for com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper
16:22:53  	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:334)
16:22:53  	at org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable.instantiate(UninstantiatedDescribable.java:208)
16:22:53  	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:466)
16:22:53  	at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:409)
16:22:53  	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:329)
16:22:53  Caused: java.lang.IllegalArgumentException: Could not instantiate {delegate=@maskPasswords(varMaskRegexes=[{name=null, value={$class=VarMaskRegex, regex=token:[^,]*}}])} for org.jenkinsci.plugins.workflow.steps.CoreWrapperStep
16:22:53  	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:334)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:305)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.DSL.invokeDescribable(DSL.java:502)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:199)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
16:22:53  	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47)
16:22:53  	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
16:22:53  	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
16:22:53  	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
16:22:53  Caused: java.lang.IllegalArgumentException: Failed to prepare maskPasswords step
16:22:53  	at org.jenkinsci.plugins.workflow.cps.DSL.invokeDescribable(DSL.java:504)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:199)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
16:22:53  	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47)
16:22:53  	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
16:22:53  	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
16:22:53  	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
16:22:53  	at githubAppToken.getToken(githubAppToken.groovy:87)
16:22:53  	at githubAppToken.call(githubAppToken.groovy:47)
16:22:53  	at githubCheck.call(githubCheck.groovy:37)
16:22:53  	at notifyBuildResult.aggregateGitHubCheck(notifyBuildResult.groovy:247)
16:22:53  	at notifyBuildResult.notifyIfNewBuildNotRunning(notifyBuildResult.groovy:225)
16:22:53  	at notifyBuildResult.aggregateGitHubCheck(notifyBuildResult.groovy:230)
16:22:53  	at notifyBuildResult.call(notifyBuildResult.groovy:113)
16:22:53  	at ___cps.transform___(Native Method)
16:22:53  	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
16:22:53  	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
16:22:53  	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
16:22:53  	at sun.reflect.GeneratedMethodAccessor695.invoke(Unknown Source)
16:22:53  	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
16:22:53  	at java.lang.reflect.Method.invoke(Method.java:498)
16:22:53  	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
16:22:53  	at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
16:22:53  	at com.cloudbees.groovy.cps.Next.step(Next.java:83)
16:22:53  	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
16:22:53  	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
16:22:53  	at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:136)
16:22:53  	at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:275)
16:22:53  	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:187)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:420)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:95)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:330)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:294)
16:22:53  	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
16:22:53  	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
16:22:53  	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
16:22:53  	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
16:22:53  	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
16:22:53  	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
16:22:53  	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
16:22:53  	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
16:22:53  	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
16:22:53  	at java.lang.Thread.run(Thread.java:750)

@petacz
Copy link

petacz commented Sep 27, 2022

Hi @pyieh,

this PR created a new issue https://issues.jenkins.io/browse/JENKINS-68885?jql=project%20%3D%20JENKINS%20AND%20component%20%3D%20mask-passwords-plugin

Do you have any plans to fix it?

Thanks

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.

6 participants