34 | * try (GiteaConnection c = Gitea.server(...).as(...).open()) { 35 | * // do stuff with the connection 36 | * } 37 | *38 | */ 39 | package org.jenkinsci.plugin.gitea.client.api; 40 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/plugin/gitea/client/impl/DefaultGiteaConnectionFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2017, CloudBees, Inc. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package org.jenkinsci.plugin.gitea.client.impl; 25 | 26 | import edu.umd.cs.findbugs.annotations.NonNull; 27 | import java.io.IOException; 28 | import org.jenkinsci.plugin.gitea.client.api.Gitea; 29 | import org.jenkinsci.plugin.gitea.client.api.GiteaConnection; 30 | import org.jenkinsci.plugin.gitea.client.spi.GiteaConnectionFactory; 31 | 32 | /** 33 | * The SPI implementation of {@link GiteaConnectionFactory}. 34 | */ 35 | public class DefaultGiteaConnectionFactory extends GiteaConnectionFactory { 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | @Override 40 | public boolean canOpen(@NonNull Gitea gitea) { 41 | return gitea.serverUrl().startsWith("http://") || gitea.serverUrl().startsWith("https://"); 42 | } 43 | 44 | /** 45 | * {@inheritDoc} 46 | */ 47 | @NonNull 48 | @Override 49 | public GiteaConnection open(@NonNull Gitea gitea) throws IOException { 50 | return new DefaultGiteaConnection(gitea.serverUrl(), gitea.as()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/plugin/gitea/client/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2017, CloudBees, Inc. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | /** 25 | * Default implementations of {@link org.jenkinsci.plugin.gitea.client.api.GiteaConnection} and 26 | * {@link org.jenkinsci.plugin.gitea.client.spi.GiteaConnectionFactory} 27 | */ 28 | package org.jenkinsci.plugin.gitea.client.impl; 29 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/plugin/gitea/client/spi/GiteaConnectionFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2017, CloudBees, Inc. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package org.jenkinsci.plugin.gitea.client.spi; 25 | 26 | import edu.umd.cs.findbugs.annotations.NonNull; 27 | import java.io.IOException; 28 | import java.util.ServiceLoader; 29 | import org.jenkinsci.plugin.gitea.client.api.Gitea; 30 | import org.jenkinsci.plugin.gitea.client.api.GiteaConnection; 31 | 32 | /** 33 | * The SPI for instantiating {@link GiteaConnection} implementations from {@link Gitea}. 34 | * All the {@link ServiceLoader} registered implementations will be filtered to only those that 35 | * {@link #canOpen(Gitea)}. In the event of multiple implementations, the one with the highest 36 | * {@link #priority(Gitea)} will be selected and then {@link #open(Gitea)} will be 37 | * called. 38 | */ 39 | public abstract class GiteaConnectionFactory { 40 | /** 41 | * SPI: confirm that this factory can open connections to the supplied builder. 42 | * 43 | * @param gitea the builder. 44 | * @return {@code true} if connections can be opened. 45 | */ 46 | public abstract boolean canOpen(@NonNull Gitea gitea); 47 | 48 | /** 49 | * SPI: return the priority with which this factory claims ownership of the supplied URL and authentication. 50 | * This method's return value is only valid after {@link #canOpen(Gitea)} has returned {@code true}. 51 | * 52 | * @param gitea the builder. 53 | * @return the priority. 54 | */ 55 | public long priority(@NonNull Gitea gitea) { 56 | return 0L; 57 | } 58 | 59 | /** 60 | * SPI: open the connection to the supplied URL with the supplied authentication. 61 | * 62 | * @param gitea the builder. 63 | * @return the connection. 64 | * @throws IOException if the connection could not be opened. 65 | * @throws InterruptedException if interrupted while opening the connection. 66 | */ 67 | @NonNull 68 | public abstract GiteaConnection open(@NonNull Gitea gitea) throws IOException, InterruptedException; 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/plugin/gitea/client/spi/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2017, CloudBees, Inc. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | /** 25 | * Client SPI for Gitea. 26 | * We use the API / SPI split to enable alternative implementations to be provided, for example so that tests can use 27 | * mock implementations. 28 | */ 29 | package org.jenkinsci.plugin.gitea.client.spi; 30 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/plugin/gitea/credentials/PersonalAccessToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2017, CloudBees, Inc. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | package org.jenkinsci.plugin.gitea.credentials; 25 | 26 | import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; 27 | import edu.umd.cs.findbugs.annotations.NonNull; 28 | import hudson.util.Secret; 29 | 30 | /** 31 | * A Gitea personal access token. 32 | */ 33 | public interface PersonalAccessToken extends StandardUsernamePasswordCredentials { 34 | /** 35 | * Gets the token. 36 | * @return the token. 37 | */ 38 | @NonNull 39 | Secret getToken(); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/plugin/gitea/credentials/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2017, CloudBees, Inc. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | /** 25 | * Gitea specific {@link com.cloudbees.plugins.credentials.Credentials} interface and default implementation. 26 | * Note we use an interface so that {@link com.cloudbees.plugins.credentials.CredentialsProvider} implementations 27 | * that store credentials external from {@link jenkins.model.Jenkins} can use {@link java.lang.reflect.Proxy} 28 | * to lazily instantiate {@link hudson.util.Secret} properties on access. 29 | */ 30 | package org.jenkinsci.plugin.gitea.credentials; 31 | -------------------------------------------------------------------------------- /src/main/java/org/jenkinsci/plugin/gitea/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2017, CloudBees, Inc. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /** 26 | *
3 | One of the great powers of pull requests is that anyone with read access to a repository can fork it, commit
4 | some changes to their fork and then create a pull request against the original repository with their changes.
5 | There are some files stored in source control that are important. For example, a Jenkinsfile
6 | may contain configuration details to sandbox pull requests in order to mitigate against malicious pull requests.
7 | In order to protect against a malicious pull request itself modifying the Jenkinsfile
to remove
8 | the protections, you can define the trust policy for pull requests from forks.
9 |
11 | Other plugins can extend the available trust policies. The default policies are: 12 |
13 |Jenkinsfile
) the contents of that file will be retrieved from the
18 | target branch on the origin repository and not from the pull request branch on the fork repository.
19 | Nobody
.
27 | https://gitea.example.com
then the URL for bob's skunkworks project
4 | repository might be https://gitea.example.com/bob/skunkworks
5 | archiveArtifacts
) will be added
3 | as assets in the release, but only if the build was successfull.
4 | https://
protocol for the Git repository.
5 |
6 | This behaviour allows you to select the SSH private key to be used for checking out sources, which will
7 | consequently force the checkout to use the ssh://
protocol.
8 |
3 | Overrides the defaults for webhook management. 4 |
5 |6 | Webhooks are used to inform Jenkins about changes to repositories. There are two ways webhooks can be 7 | configured: 8 |
9 |18 | The Manage Jenkins » Configure System › Gitea Server allows defining the list of 19 | servers. Each server can be associated with credentials. If credentials are defined then the default behaviour 20 | is to use those credentials to automatically manage the webhooks of all repositories that Jenkins is interested 21 | in. If no credentials are defined then the default behaviour is to require the user to manually configure 22 | webhooks. 23 |
24 |10 | { 11 | ... 12 | "repository":{ 13 | ... 14 | "full_name": "example/reponame", 15 | ... 16 | "html_url": "http://git.example.org:3000/example/reponame", 17 | ... 18 | }, 19 | ... 20 | } 21 |22 | You are looking for the
repository/html_url
value and you should remove the
23 | repository/full_name
part at the end to determine the Alias URL to specify, i.e. using the example
24 | payload above, the alias URL would be http://git.example.org:3000/
25 | http://internal.example.com:7990/gitea
3 | and https://gitea.example.com
.
4 | {0}
3 | GiteaServer.validateInterrupted=Interrupted while trying to validate credentials
4 | GiteaServer.versionInterrupted=Interrupted while trying to determine server version
5 | GiteaServer.invalidUrl=Invalid URL: {0}
6 | GiteaServer.serverVersion=Gitea Version: {0}
7 | GiteaServer.cannotConnect=Could not communicate with server: {0}
8 | GiteaServer.credentialsNotResolved=Cannot resolve suitable credentials with id: {0}
9 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugin/gitea/tasks/GiteaAssetPublisher/config.jelly:
--------------------------------------------------------------------------------
1 |
2 |