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

Hosting request for multibranch-pipeline-initial-trigger plugin #3551

Closed
joutvhu opened this issue Sep 28, 2023 · 21 comments
Closed

Hosting request for multibranch-pipeline-initial-trigger plugin #3551

joutvhu opened this issue Sep 28, 2023 · 21 comments
Labels
bot-check-complete Automated hosting checks passed hosting-request Request to host a component in jenkinsci security-audit-done The hosting request code passed the security audit with success

Comments

@joutvhu
Copy link

joutvhu commented Sep 28, 2023

Repository URL

https://github.com/joutvhu/multibranch-pipeline-initial-trigger

New Repository Name

multibranch-pipeline-initial-trigger-plugin

Description

This plugin help to trigger the Multi-Branch Pipeline Job after it is created.

GitHub users to have commit permission

@joutvhu

Jenkins project users to have release permission

joutvhu

Issue tracker

GitHub issues

@joutvhu joutvhu added the hosting-request Request to host a component in jenkinsci label Sep 28, 2023
@github-actions
Copy link

Hello from your friendly Jenkins Hosting Checker

It appears you have some issues with your hosting request. Please see the list below and correct all issues marked Required. Your hosting request will not be approved until these issues are corrected. Issues marked with Warning or Info are just recommendations and will not stall the hosting process.

  • ⛔ Required: The following usernames in 'Jenkins project users to have release permission' need to log into Jira: @joutvhu (reports are re-synced hourly, wait to re-check for a bit after logging in)
  • ⛔ Required: The following usernames in 'Jenkins project users to have release permission' need to log into Artifactory: @joutvhu (reports are re-synced hourly, wait to re-check for a bit after logging in)
  • ⚠️ Warning: No pom.xml detected.

You can re-trigger a check by editing your hosting request or by commenting /hosting re-check

@jenkins-cert-app
Copy link
Collaborator

Security audit, information and commands

The security team is auditing all the hosting requests, to ensure a better security by default.

This message informs you that a Jenkins Security Scan was triggered on your repository.
It takes ~10 minutes to complete.

Commands

The bot will parse all comments, and it will check if any line start with a command.

Security team only:

  • /audit-ok => the audit is complete, the hosting can continue 🎉.
  • /audit-skip => the audit is not necessary, the hosting can continue 🎉.
  • /audit-findings => the audit reveals some issues that require corrections ✏️.

Anyone:

  • /request-security-scan => the findings from the Jenkins Security Scan were corrected, this command will re-scan your repository 🔍.
  • /audit-review => the findings from the audit were corrected, this command will ping the security team to review the findings 👀. It's only applicable when the previous audit required changes.

Only one command can be requested per comment.

(automatically generated message, version: 1.19.14)

@jenkins-cert-app jenkins-cert-app added the security-audit-todo The security team needs to audit the hosting request code label Sep 29, 2023
@jenkins-cert-app
Copy link
Collaborator

The Jenkins Security Scan discovered 3 finding(s) 🔍.
For each of them, either apply the recommended correction, suppress the warning or provide a justification.

Once you're done, either re-run the scan with /request-security-scan or request the Security team to review your justifications with /audit-review.


Stapler: Missing POST/RequirePOST annotation

You can find detailed information about this finding here.

PipelineTriggerProperty.java#106
Potential CSRF vulnerability: If DescriptorImpl#doAutoCompleteActionJobsToTriggerOnRunDelete connects to user-specified URLs, modifies state, or is expensive to run, it should be annotated with @POST or @RequirePOST
PipelineTriggerProperty.java#96
Potential CSRF vulnerability: If DescriptorImpl#doAutoCompleteDeleteActionJobsToTrigger connects to user-specified URLs, modifies state, or is expensive to run, it should be annotated with @POST or @RequirePOST
PipelineTriggerProperty.java#86
Potential CSRF vulnerability: If DescriptorImpl#doAutoCompleteCreateActionJobsToTrigger connects to user-specified URLs, modifies state, or is expensive to run, it should be annotated with @POST or @RequirePOST

@jenkins-cert-app jenkins-cert-app added security-audit-needs-correction The security audit revealed issues that must be corrected from the hosting request and removed security-audit-todo The security team needs to audit the hosting request code labels Sep 29, 2023
@NotMyFault
Copy link
Member

Please recreate your repository using the Jenkins archetype for the maven plugin as base layout: https://www.jenkins.io/doc/developer/tutorial/create/
Choosing "4" and modifying the example java classes.

@joutvhu
Copy link
Author

joutvhu commented Sep 29, 2023

/request-security-scan

@jenkins-cert-app jenkins-cert-app added security-audit-todo The security team needs to audit the hosting request code and removed security-audit-needs-correction The security audit revealed issues that must be corrected from the hosting request labels Sep 29, 2023
@jenkins-cert-app
Copy link
Collaborator

The Jenkins Security Scan did not find anything dangerous with your plugin, congratulations! 🎉


💡 The Security team recommends that you are setting up the scan in your repository by following our guide.

@jenkins-cert-app jenkins-cert-app added security-audit-done The hosting request code passed the security audit with success and removed security-audit-todo The security team needs to audit the hosting request code labels Sep 29, 2023
@joutvhu
Copy link
Author

joutvhu commented Sep 29, 2023

@NotMyFault I have changed the project layout to maven layout

@joutvhu
Copy link
Author

joutvhu commented Sep 29, 2023

/hosting re-check

@github-actions
Copy link

Hello from your friendly Jenkins Hosting Checker

It appears you have some issues with your hosting request. Please see the list below and correct all issues marked Required. Your hosting request will not be approved until these issues are corrected. Issues marked with Warning or Info are just recommendations and will not stall the hosting process.

  • ⛔ Required: Your baseline specified does not meet the minimum Jenkins version required, please update <jenkins.version>2.277.4</jenkins.version> to at least 2.387.3 in your pom.xml. Take a look at the baseline recommendations.
  • ⛔ Required: The parent pom version '4.32' should be at least '4.71' or higher.
  • ⛔ Required: The following usernames in 'Jenkins project users to have release permission' need to log into Jira: @joutvhu (reports are re-synced hourly, wait to re-check for a bit after logging in)
  • ⛔ Required: The following usernames in 'Jenkins project users to have release permission' need to log into Artifactory: @joutvhu (reports are re-synced hourly, wait to re-check for a bit after logging in)

You can re-trigger a check by editing your hosting request or by commenting /hosting re-check

@joutvhu
Copy link
Author

joutvhu commented Sep 29, 2023

/hosting re-check

@github-actions
Copy link

Hello from your friendly Jenkins Hosting Checker

It appears you have some issues with your hosting request. Please see the list below and correct all issues marked Required. Your hosting request will not be approved until these issues are corrected. Issues marked with Warning or Info are just recommendations and will not stall the hosting process.

  • ⛔ Required: The following usernames in 'Jenkins project users to have release permission' need to log into Jira: @joutvhu (reports are re-synced hourly, wait to re-check for a bit after logging in)
  • ⛔ Required: The following usernames in 'Jenkins project users to have release permission' need to log into Artifactory: @joutvhu (reports are re-synced hourly, wait to re-check for a bit after logging in)

You can re-trigger a check by editing your hosting request or by commenting /hosting re-check

@github-actions
Copy link

Hello from your friendly Jenkins Hosting Checker

It looks like you have everything in order for your hosting request. A member of the Jenkins hosting team will check over things that I am not able to check(code review, README content, etc) and process the request as quickly as possible. Thank you for your patience.

Hosting team members can host this request with /hosting host

@github-actions github-actions bot added bot-check-complete Automated hosting checks passed and removed needs-fix labels Sep 30, 2023
@NotMyFault
Copy link
Member

What would be a practical use case of this plugin?

@joutvhu
Copy link
Author

joutvhu commented Sep 30, 2023

@NotMyFault I use it to load the Jenkinsfile. See the below example:

pipeline {
    agent any
    parameters {
        choice choices: ['dev', 'uat'], name: 'DEPLOY_TO'
    }
    stages {
        stage('Deploy to Nexus and Push Tag') {
            when {
                // Apply for branchs
                environment name: 'TAG_NAME', value: null
            }
            steps {
                 ...
            }
        }
        stage('Deploy to Server') {
            when {
                 // Apply for tags
                 not {
                    environment name: 'TAG_NAME', value: null
                 }
            }
            steps {
                  // Use params.DEPLOY TO to select the server
            }
       }
    }
}

When a tag is created it will not have the Build with Parameters button for the first build.
This plugin will be used to trigger the tag as soon as it is created to load the Jenkinsfile.
Once triggered by the plugin, the Build with Parameters button will be available to the user.

@NotMyFault
Copy link
Member

When a tag is created it will not have the Build with Parameters button for the first build.

That sounds more like a bug in the pipeline plugin because building with parameters is available for first builds in other job types.

I'd recommend filing an issue on Jira with a clear description and steps to replicate. Given you have already investigated into it, don't hesitate to raise a PR. That would be much appreciated.

@joutvhu
Copy link
Author

joutvhu commented Oct 6, 2023

@NotMyFault
I think that is not an issue.
The parameters are declared in the Jenkinsfile. So if the job has not been run yet, it will not know that there are parameters.
It must be running for the Jenkinsfile to be cloned from git.
Just like I change the Jenkinsfile on git, the changes (ex: change parameters) will not be applied until it is run.

@joutvhu
Copy link
Author

joutvhu commented Oct 6, 2023

I have made changes based on your feedback.

@timja
Copy link
Member

timja commented Oct 6, 2023

The parameters are declared in the Jenkinsfile. So if the job has not been run yet, it will not know that there are parameters.

there's an issue somewhere I think, I believe I remember @jglick saying that this could be fixed for declarative but probably not for scripted.

@jglick
Copy link
Contributor

jglick commented Oct 6, 2023

One solution that was considered in the past would work only for Declarative (tracked as JENKINS-41929), but would not be straightforward as you would need to fetch Jenkinsfile from SCM when creating a branch project and parse Groovy. A somewhat simpler alternative would be to load job properties from a separate YAML file in the repository, using syntax similar to configuration-as-code.

A much simpler change which should work transparently for at least the common case of the first build of a “pull request” (or similar concept depending on SCM) would be for workflow-multibranch to copy job properties from the base branch when creating a new branch project. See jenkinsci/parallel-test-executor-plugin#226 an example of using ChangeRequestSCMHead.getTarget for a similar purpose. This would not handle the tag use case however.

Another option would just be to allow users to configure job properties including parameters on the repository folder rather than in SCM. (Would not work for children of an organization folder.)

multibranch-pipeline-initial-trigger is clearly a workaround for what should be fixed properly in multibranch Pipeline. I am not exactly clear on why it needs to exist, though; the default behavior of multibranch is already to trigger an initial build when a new branch project is created.

@joutvhu
Copy link
Author

joutvhu commented Oct 6, 2023

@jglick The initial build will not be triggered when the tag is created.

@jglick
Copy link
Contributor

jglick commented Oct 6, 2023

Not sure why not; fix that instead.

@NotMyFault NotMyFault closed this as not planned Won't fix, can't repro, duplicate, stale Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot-check-complete Automated hosting checks passed hosting-request Request to host a component in jenkinsci security-audit-done The hosting request code passed the security audit with success
Projects
None yet
Development

No branches or pull requests

5 participants