Skip to content

Commit

Permalink
Merge branch 'master' into support_param_in_ls_remote
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkEWaite committed Aug 24, 2024
2 parents 7b48e85 + fea4aad commit 864a20b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 8 deletions.
36 changes: 34 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ This removes remote tracking branches and tags from the local workspace if they
----
checkout scmGit(
branches: [[name: 'master']],
extensions: [pruneStaleBranch(), pruneTags(true)],
extensions: [ pruneStaleBranch(), pruneTags(true) ],
userRemoteConfigs: [[url: 'https://github.com/jenkinsci/ws-cleanup-plugin']])
----

Expand Down Expand Up @@ -324,6 +324,8 @@ If polling finds a change worthy of a build, a build will be triggered.
This allows a notify script to remain the same for all Jenkins jobs.
Or if you have multiple repositories under a single repository host application (such as Gitosis), you can share a single post-receive hook script with all the repositories.

When notifyCommit is successful, the list of triggered projects is returned.

The `token` parameter is required by default as a security measure, but can be disabled by the following link:https://www.jenkins.io/doc/book/managing/system-properties/[system property]:

....
Expand All @@ -337,7 +339,27 @@ It has two modes:
* `disabled` - Fully disables the access token mechanism and allows all requests to `notifyCommit`
to be unauthenticated. *This option is insecure and is not recommended.*

When notifyCommit is successful, the list of triggered projects is returned.
You can set the `NOTIFY_COMMIT_ACCESS_CONTROL` value with either a link:https://www.jenkins.io/doc/book/managing/system-properties/[system property] or a link:https://www.jenkins.io/doc/book/managing/groovy-hook-scripts/[Groovy hook script].

[[using-a-system-property-push-notification]]
Using a system property::

The `NOTIFY_COMMIT_ACCESS_CONTROL` value can be set from the command line that starts Jenkins.
This method is useful for environments where initial Jenkins settings are managed with command line arguments.
+
....
java -Dhudson.plugins.git.GitStatus.NOTIFY_COMMIT_ACCESS_CONTROL=disabled-for-polling -jar jenkins.war
....

[[using-a-groovy-script-push-notification]]
Using a Groovy script::

The `NOTIFY_COMMIT_ACCESS_CONTROL` value can be set using a Groovy script placed in the `init.groovy.d` subdirectory of the Jenkins home directory.
This method is useful for environments where Jenkins settings are managed with link:https://www.jenkins.io/doc/book/managing/groovy-hook-scripts/#post-initialization-script-init-hook[Groovy post-initialization scripts].
+
----
hudson.plugins.git.GitStatus.NOTIFY_COMMIT_ACCESS_CONTROL='disabled-for-polling'
----

[#enabling-jgit]
=== Enabling JGit
Expand Down Expand Up @@ -1058,6 +1080,16 @@ Path::

File or directory to be included in the checkout

[source,groovy]
----
checkout scmGit(
branches: [[name: 'master']],
extensions: [
sparseCheckout(sparseCheckoutPaths: [[path: 'src'], [path: 'Makefile']])
],
userRemoteConfigs: [[url: 'https://github.com/jenkinsci/git-plugin.git']])
----

[#git-lfs-pull-after-checkout]
==== Git LFS pull after checkout

Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
</scm>

<properties>
<revision>5.3.1</revision>
<revision>5.4.1</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<jenkins.baseline>2.440</jenkins.baseline>
Expand All @@ -89,7 +89,7 @@
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-${jenkins.baseline}.x</artifactId>
<version>3276.vcd71db_867fb_2</version>
<version>3289.v3ff9637cd241</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -165,7 +165,7 @@
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.16.1</version>
<version>3.16.2</version>
<scope>test</scope>
</dependency>
<!--Credential Binding Plugin-->
Expand Down Expand Up @@ -296,7 +296,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.4.0</version>
<version>3.5.0</version>
<configuration>
<configLocation>google_checks.xml</configLocation>
<failOnViolation>true</failOnViolation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jenkinsci.plugins.gitclient.GitClient;
import org.jenkinsci.plugins.gitclient.UnsupportedCommand;
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import edu.umd.cs.findbugs.annotations.NonNull;

Expand Down Expand Up @@ -52,10 +53,11 @@ public void determineSupportForJGit(GitSCM scm, @NonNull UnsupportedCommand cmd)
}

@Extension
@Symbol("sparseCheckout")
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
@Override
public String getDisplayName() {
return "Sparse Checkout paths";
return "Sparse checkout paths";
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/jenkins/plugins/git/GitSCMSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,10 @@ public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context,
public FormValidation doCheckRemote(@AncestorInPath Item item,
@QueryParameter String credentialsId,
@QueryParameter String remote) throws IOException, InterruptedException {
Jenkins.get().checkPermission(Jenkins.MANAGE);
if (item == null && !Jenkins.get().hasPermission(Jenkins.MANAGE) ||
item != null && !item.hasPermission(Item.CONFIGURE)) {
return FormValidation.warning("Not allowed to modify remote");
}
return isFIPSCompliantTLS(credentialsId, remote) ? FormValidation.ok() : FormValidation.error(hudson.plugins.git.Messages.git_fips_url_notsecured());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ private String randomPipelineExtensions() {
"pruneTags()",
"pruneTags(false)",
"pruneTags(true)",
"sparseCheckout(sparseCheckoutPaths: [[path: 'src'], [path: 'Makefile']])",
"submodule(disableSubmodules: true)",
"submodule(depth: 1, shallow: true)",
"submodule(parentCredentials: true, recursiveSubmodules: true, threads: 13)",
Expand Down

0 comments on commit 864a20b

Please sign in to comment.