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

Configurable anonymous access to the list of failure causes #31

Merged
merged 5 commits into from
Jan 15, 2015

Conversation

dcoraboeuf
Copy link
Contributor

In some contexts, it is interesting to provide authorised users a read-only access to list of failure causes.

This pull request creates a new ViewCauses permission, granted automatically for users having already UpdateCauses. When a user has this ViewCauses permission granted, he can access the list of existing failures.

Best regards,
Damien.

@jenkinsadmin
Copy link
Member

Thank you for a pull request! Please check this document for how the Jenkins project handles pull requests

@dcoraboeuf
Copy link
Contributor Author

The build failed because of Checkstyle errors - but no detail is given in the build :( Any idea?

@dcoraboeuf
Copy link
Contributor Author

Checkstyle issue fixed.

@@ -32,7 +32,7 @@ def f = namespace(lib.FormTagLib)
def l = namespace(lib.LayoutTagLib)
def j = namespace(lib.JenkinsTagLib)

l.layout(permission: PluginImpl.UPDATE_PERMISSION) {
Copy link
Member

Choose a reason for hiding this comment

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

Since VIEW_PERMISSION is inferred by UPDATE_PERMISSION you should be able to put permission: PluginImpl.VIEW_PERMISSION here for safety.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@rsandell
Copy link
Member

A test case or two testing the permissions are working as expected would be nice.

Example:
Permissions: Alice can update, Bob can only view, Charles can't do anything (only overall read).

  • Alice and bob sees the link on Jenkins Root and job pages, Charles does not.
  • Alice and bob can navigate to the action page, Charles can not.
  • Alice can open the details page and sees the new button, Bob and Charles does not.

There are some helper methods in JenkinsRule to help you setup security and test these scenarios.

@dcoraboeuf
Copy link
Contributor Author

I'll work on the tests a bit later today.

@AnneTheAgile
Copy link
Contributor

Although it doesn't show up here, the checkstyle still seems to be failing?
https://jenkins.ci.cloudbees.com/job/plugins/job/build-failure-analyzer-plugin/90/console

INFO: Stopping build-failure-analyzer
Tests run: 14, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.117 sec

Results :

Tests run: 148, Failures: 0, Errors: 0, Skipped: 0

[JENKINS] Recording test results
[INFO] 
[INFO] --- maven-checkstyle-plugin:2.13:check (test-check) @ build-failure-analyzer ---
[INFO] 
[INFO] There are 1 checkstyle errors.
[ERROR] CauseManagement.java[118:78] (whitespace) OperatorWrap: '||' should be on a new line.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17:57 min
[INFO] Finished at: 2015-01-14T07:57:21-05:00
[INFO] Final Memory: 57M/161M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.13:check (test-check) on project build-failure-analyzer: You have 1 Checkstyle violation. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.13:check (test-check) on project build-failure-analyzer: You have 1 Checkstyle violation.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.jvnet.hudson.maven3.launcher.Maven32Launcher.main(Maven32Launcher.java:132)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
    at jenkins.maven3.agent.Maven32Main.launch(Maven32Main.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:136)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:71)
    at hudson.remoting.UserRequest.perform(UserRequest.java:121)
    at hudson.remoting.UserRequest.perform(UserRequest.java:49)
    at hudson.remoting.Request$2.run(Request.java:324)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.maven.plugin.MojoFailureException: You have 1 Checkstyle violation.
    at org.apache.maven.plugin.checkstyle.CheckstyleViolationCheckMojo.execute(CheckstyleViolationCheckMojo.java:582)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 30 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[JENKINS] Archiving /scratch/jenkins/workspace/plugins/build-failure-analyzer-plugin/pom.xml to com.sonyericsson.jenkins.plugins.bfa/build-failure-analyzer/1.11.1-SNAPSHOT/build-failure-analyzer-1.11.1-SNAPSHOT.pom
Sending artifact delta relative to plugins » build-failure-analyzer-plugin » Build Failure Analyzer #88
Archived 1 artifacts
Archive block size is 32768
Received 0 blocks and 12452 bytes
Compression is 0.0%
Took 0.29 sec
channel stopped
Email was triggered for: Failure - Any
Sending email for trigger: Failure - Any
Sending email to: [email protected] [email protected]
Putting comment on the pull request
Finished: FAILURE

@dcoraboeuf
Copy link
Contributor Author

On last build (https://jenkins.ci.cloudbees.com/job/plugins/job/build-failure-analyzer-plugin/92/console), it looks OK. I have made a correction since then: 5f3e14e

@rsandell
Copy link
Member

I'll work on the tests a bit later today.

No worries, I won't be able to look at it until earliest tomorrow anyways.

@dcoraboeuf
Copy link
Contributor Author

Another thing, if this pull request is merged back and released, the Wiki page at https://wiki.jenkins-ci.org/display/JENKINS/Build+Failure+Analyzer will have also to be adapted.

@rsandell
Copy link
Member

Most likely, I hope someone remembers to do that ;) I barely remember to update the changelog when I release :D

@dcoraboeuf
Copy link
Contributor Author

I have tried to create some unit tests (see 4686648, on a separate branch) but I face the following error when running them:

com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 500 org.apache.commons.jelly.JellyTagException: jar:file:/Users/damien/.m2/repository/org/jenkins-ci/main/jenkins-core/1.480/jenkins-core-1.480.jar!/lib/layout/layout.jelly:237:26: 
<d:invokeBody> org.apache.commons.jelly.JellyTagException: jar:file:/Users/damien/.m2/repository/org/jenkins-ci/main/jenkins-core/1.480/jenkins-core-1.480.jar!/lib/layout/main-panel.jelly:36:21:
<d:invokeBody> Cannot invoke method isGraphsEnabled() on null object for http://localhost:55465/failure-cause-management/

Does it ring a bell?

@dcoraboeuf
Copy link
Contributor Author

Funny enough, when I run the test on the command line, it's working file. It's only in my IDE (Intellij) where I have this problem. I will go on using the command line right now.

@dcoraboeuf
Copy link
Contributor Author

I've now added 4 unit tests to test different combinations of security accesses. They work when ran locally using the command line (mvn clean verify). Waiting for the Jenkins' feedback.

Damien.

@rsandell
Copy link
Member

Some types of source code changes needs to have an updated manifest file for the hpi, running the tests from IDEA doesn't generate that metadata, but running mvn package or mvn hpi:run etc. once will generate it and you can normally go back to running from the IDE again.

@dcoraboeuf
Copy link
Contributor Author

Understood. Thanks for the tip.

rsandell added a commit that referenced this pull request Jan 15, 2015
Configurable anonymous access to the list of failure causes
@rsandell rsandell merged commit ae11da7 into jenkinsci:master Jan 15, 2015
@dcoraboeuf
Copy link
Contributor Author

Do you know when we could expect a new release containing this enhancement? It's for us to know if we have to wait or if we have to patch our Jenkins in the meantime? We'll use this feature to provide documentation to our different projects.

@rsandell
Copy link
Member

I think I can cut a release now

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.

4 participants