matrixji opened a new issue, #7261:
URL: https://github.com/apache/incubator-devlake/issues/7261

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### What happened
   
   `_tool_jenkins_builds.triggered_by` field is not collected, but in my test 
Jenkins job, I do use `job00` -> `job01`is 
   
   
![image](https://github.com/apache/incubator-devlake/assets/183388/b5202249-d524-4069-afbe-9e1046a941c4)
   
   
   ### What do you expect to happen
   
   `_tool_jenkins_builds.triggered_by` to be collected.
   
   This is my local patched version:
   
![image](https://github.com/apache/incubator-devlake/assets/183388/d983ade7-75e3-4db0-b965-64c3d31c30de)
   
   
   
   
   ### How to reproduce
   
   N/A
   
   ### Anything else
   
   It seems there is some Incorrect logic for handling `actions` in Jenkins's 
API JSON raw data.
   
   The `actions` in raw JSON from Jenkins's API are like below:
   ```json
   "actions": [
                   {
                       "_class": "hudson.model.CauseAction",
                       "causes": [
                           {
                               "_class": 
"org.jenkinsci.plugins.workflow.support.steps.build.BuildUpstreamCause",
                               "shortDescription": "Started by upstream project 
\"job00\" build number 3",
                               "upstreamBuild": 3,
                               "upstreamProject": "job00",
                               "upstreamUrl": "job/job00/"
                           }
                       ]
                   },
                   {},
                   {
                       "_class": "hudson.model.ParametersAction"
                   },
                   {
                       "_class": "jenkins.metrics.impl.TimeInQueueAction"
                   },
                   {
                       "_class": 
"org.jenkinsci.plugins.workflow.libs.LibrariesAction"
                   },
                   {},
                   {
                       "_class": "hudson.plugins.git.util.BuildData",
                       "lastBuiltRevision": {
                           "SHA1": "45804691223635953f311cf31a10c632553bbfc3",
                           "branch": [
                               {
                                   "name": "refs/remotes/origin/main"
                               }
                           ]
                       },
                       "remoteUrls": [
                           "https://gitee.com/jb/googletest.git";
                       ]
                   },
                   {},
                   {},
                   {
                       "_class": 
"org.jenkinsci.plugins.displayurlapi.actions.RunDisplayAction"
                   },
                   {
                       "_class": 
"org.jenkinsci.plugins.pipeline.modeldefinition.actions.RestartDeclarativePipelineAction"
                   },
                   {},
                   {
                       "_class": 
"org.jenkinsci.plugins.workflow.job.views.FlowGraphAction"
                   },
                   {},
                   {},
                   {}
               ]
   ```
   
   Each action in actions will only have one key/value pair.
   
   
https://github.com/matrixji/incubator-devlake/blob/ef714f90c60343c5fdd45a5e6d1dbcfcc53e5c5d/backend/plugins/jenkins/tasks/build_extractor.go#L78
   
   ```
                        for _, a := range body.Actions {
                                if a.LastBuiltRevision == nil {
                                        continue
                                }
   ```
   It seems we will skip all actions without the `lastBuiltRevision` key. That 
is to say except for the `lastBuiltRevision` field, all other fields will not 
proceed.
   
   
   ### Version
   
   v0.21.0-beta9@71f3e1f
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@devlake.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to