Skip to content

Commit

Permalink
Merge pull request #9 from jenkinsci/modernize
Browse files Browse the repository at this point in the history
Modernize the plugin
  • Loading branch information
NotMyFault authored Dec 22, 2022
2 parents 146f940 + f6f06a4 commit 7674859
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 66 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Note: additional setup is required, see https://www.jenkins.io/redirect/continuous-delivery-of-plugins

name: cd
on:
workflow_dispatch:
check_run:
types:
- completed

jobs:
maven-cd:
uses: jenkins-infra/github-reusable-workflows/.github/workflows/maven-cd.yml@v1
secrets:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target/
/work/
*.hpl
*.hpl
.idea
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.4</version>
</extension>
</extensions>
3 changes: 3 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-Pconsume-incrementals
-Pmight-produce-incrementals
-Dchangelist.format=%d.v%s
4 changes: 4 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
buildPlugin(useContainerAgent: true, configurations: [
[platform: 'linux', jdk: '11'],
[platform: 'linux', jdk: '17']
])
35 changes: 12 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.509.2</version>
<version>4.53</version>
<relativePath />
</parent>

<groupId>sic.software</groupId>
<name>Keychains and Provisioning Profiles Management</name>
<description>This Jenkins plugin integrates a keychains and provisioning profiles managment for iOS and OSX projects build on a mac.</description>
<artifactId>kpp-management-plugin</artifactId>
<version>1.0.1-SNAPSHOT</version>
<version>${changelist}</version>
<packaging>hpi</packaging>
<url>http://wiki.jenkins-ci.org/display/JENKINS/Keychains+and+Provisioning+Profiles+Plugin</url>
<scm>
<connection>scm:git:ssh://github.com/jenkinsci/kpp-management-plugin.git</connection>
<connection>scm:git:https://github.com/jenkinsci/kpp-management-plugin.git</connection>
<developerConnection>scm:git:ssh://[email protected]/jenkinsci/kpp-management-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/kpp-management-plugin</url>
</scm>
Expand All @@ -27,38 +27,27 @@
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<developer>
<id>michaelb</id>
<name>Michael Bär</name>
<email>[email protected]</email>
</developer>
</developers>

<!-- get every artifact through repo.jenkins-ci.org, which proxies all the artifacts that we need -->
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<build>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>1.95</version>
</plugin>
</plugins>
</build>

<properties>
<changelist>999999-SNAPSHOT</changelist>
<jenkins.version>2.361.4</jenkins.version>
<!-- TODO fix violations -->
<spotbugs.threshold>High</spotbugs.threshold>
</properties>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import jenkins.model.Jenkins;
import org.kohsuke.stapler.DataBoundConstructor;

/**
Expand Down Expand Up @@ -100,13 +102,11 @@ public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener l
/**
* Copy the keychains configured for this build job to the workspace of the job.
* @param build the current build
* @throws IOException
* @throws InterruptedException
*/
private void copyKeychainsToWorkspace(AbstractBuild build) throws IOException, InterruptedException {
FilePath projectWorkspace = build.getWorkspace();

Hudson hudson = Hudson.getInstance();
Jenkins hudson = Jenkins.get();
FilePath hudsonRoot = hudson.getRootPath();

if (copiedKeychains == null) {
Expand All @@ -131,7 +131,7 @@ public DescriptorImpl getDescriptor() {
}

/**
* Descriptor of the {@link KPPKeychainBuildWrapper}.
* Descriptor of the KPPKeychainBuildWrapper.
*/
@Extension
public static final class DescriptorImpl extends BuildWrapperDescriptor {
Expand Down
16 changes: 6 additions & 10 deletions src/main/java/com/sic/plugins/kpp/KPPManagementLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import java.security.NoSuchAlgorithmException;
import java.util.List;
import javax.servlet.ServletException;

import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.apache.commons.fileupload.FileItem;
import org.kohsuke.stapler.StaplerProxy;
Expand Down Expand Up @@ -103,15 +105,12 @@ public String getProvisioningProfilesPath() {
*
* @param req Request
* @param rsp Response
* @throws ServletException
* @throws IOException
* @throws NoSuchAlgorithmException
*/
public void doUploadFile(StaplerRequest req, StaplerResponse rsp) throws
ServletException,
IOException,
NoSuchAlgorithmException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.get().checkPermission(Hudson.ADMINISTER);

FileItem file = req.getFileItem("file");
if (file == null || file.getSize() == 0) {
Expand All @@ -138,15 +137,12 @@ public void doUploadFile(StaplerRequest req, StaplerResponse rsp) throws
*
* @param req Request
* @param rsp Response
* @throws ServletException
* @throws IOException
* @throws NoSuchAlgorithmException
*/
public void doSave(StaplerRequest req, StaplerResponse rsp) throws
ServletException,
IOException,
NoSuchAlgorithmException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.get().checkPermission(Hudson.ADMINISTER);

JSONObject data = req.getSubmittedForm();
List<KPPKeychain> keychains = req.bindJSONToList(KPPKeychain.class, data.get("keychain"));
Expand Down Expand Up @@ -175,15 +171,15 @@ public String getUrlName() {

@Override
public Object getTarget() {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.get().checkPermission(Hudson.ADMINISTER);
KPPKeychainsProvider.getInstance().update();
KPPProvisioningProfilesProvider.getInstance().update();
return this;
}

@Override
public void save() throws IOException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.get().checkPermission(Hudson.ADMINISTER);
KPPKeychainsProvider.getInstance().save();
KPPProvisioningProfilesProvider.getInstance().save();
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/sic/plugins/kpp/KPPNodeProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import hudson.model.Node;
import hudson.slaves.NodeProperty;
import hudson.slaves.NodePropertyDescriptor;
import jenkins.model.Jenkins;
import org.kohsuke.stapler.DataBoundConstructor;

/**
Expand Down Expand Up @@ -63,7 +64,7 @@ public String getProvisioningProfilesPath() {
public static KPPNodeProperty getCurrentNodeProperties() {
KPPNodeProperty property = Computer.currentComputer().getNode().getNodeProperties().get(KPPNodeProperty.class);
if(property == null) {
property = Hudson.getInstance().getGlobalNodeProperties().get(KPPNodeProperty.class);
property = Jenkins.get().getGlobalNodeProperties().get(KPPNodeProperty.class);
}
return property;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import jenkins.model.Jenkins;
import org.kohsuke.stapler.DataBoundConstructor;

/**
Expand Down Expand Up @@ -103,13 +105,11 @@ public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener l
/**
* Copy the provisioning profiles configured for this job to the mobile provisioning profile path of the node or master, where the job is executed.
* @param build current build
* @throws IOException
* @throws InterruptedException
*/
private void copyProvisioningProfiles(AbstractBuild build) throws IOException, InterruptedException {

Hudson hudson = Hudson.getInstance();
FilePath hudsonRoot = hudson.getRootPath();
Jenkins jenkins = Jenkins.get();
FilePath hudsonRoot = jenkins.getRootPath();
VirtualChannel channel;
String toProvisioningProfilesDirectoryPath = null;

Expand Down Expand Up @@ -235,4 +235,3 @@ public boolean tearDown(AbstractBuild build, BuildListener listener)
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public String getCodeSigningIdentityName() {

/**
* Set the code singing identity name.
* @param codeSigningIdentityName
*/
public void setCodeSigningIdentityName(String codeSigningIdentityName) {
this.codeSigningIdentityName = codeSigningIdentityName;
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/sic/plugins/kpp/model/KPPKeychain.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import hudson.util.Secret;
import java.io.Serializable;
import java.util.List;

import jenkins.model.Jenkins;
import org.kohsuke.stapler.DataBoundConstructor;

/**
Expand Down Expand Up @@ -114,7 +116,6 @@ public final String getDescription() {

/**
* Set description.
* @param description
*/
public final void setDescription(String description) {
this.description = description;
Expand Down Expand Up @@ -163,7 +164,7 @@ public int hashCode() {
* @return descriptor
*/
public Descriptor getDescriptor() {
Descriptor ds = Hudson.getInstance().getDescriptorOrDie(getClass());
Descriptor ds = Jenkins.get().getDescriptorOrDie(getClass());
return ds;
}

Expand All @@ -178,4 +179,4 @@ public String getDisplayName() {
return Messages.KPPKeychain_DisplayName();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public String getKeychainFileName() {

/**
* Get the keychain from a given string. The string has to start with the keychain filename.
* @param keychainString
* @return keychain
*/
public static KPPKeychain getKeychainFromString(String keychainString) {
Expand All @@ -186,7 +185,6 @@ public static KPPKeychain getKeychainFromString(String keychainString) {

/**
* Concatenation keychain filename and keychain description in one string.
* @param k
* @return concatenated keychain string
*/
private static String getKeychainString(KPPKeychain k) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
import java.io.File;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;

import jenkins.model.Jenkins;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;

Expand Down Expand Up @@ -136,7 +139,7 @@ public boolean equals(Object obj) {
return false;
}
final KPPProvisioningProfile other = (KPPProvisioningProfile) obj;
if ((this.fileName == null) ? (other.fileName != null) : !this.fileName.equals(other.fileName)) {
if (!Objects.equals(this.fileName, other.fileName)) {
return false;
}
return true;
Expand All @@ -154,7 +157,7 @@ public int hashCode() {
* @return descriptor
*/
public Descriptor<KPPProvisioningProfile> getDescriptor() {
Descriptor ds = Hudson.getInstance().getDescriptorOrDie(getClass());
Descriptor ds = Jenkins.get().getDescriptorOrDie(getClass());
return ds;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public static ExtensionList<KPPBaseKeychainsProvider> all() {
/**
* Call this method to update keychains from save action. The keychains from save action are merged into current keychains list.
* Then this list is sychnronized with the upload folder.
* @param keychainsAfterSave
*/
public void updateKeychainsFromSave(List<KPPKeychain>keychainsFromSave) {
List<KPPKeychain> ksCurrent = new ArrayList<KPPKeychain>(getKeychains());
Expand Down Expand Up @@ -134,7 +133,6 @@ public void updateKeychainsFromSave(List<KPPKeychain>keychainsFromSave) {

/**
* Checks if a given file item is a keychain file.
* @param item
* @return true, if it is a keychain file.
*/
public boolean isKeychainFile(FileItem item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ public String getUploadDirectoryPath() {

/**
* Store uploaded file inside upload directory.
* @param fileItemToUpload
* @throws FileNotFoundException
* @throws IOException
*/
public void upload(FileItem fileItemToUpload) throws FileNotFoundException, IOException {
// save uploaded file
Expand Down Expand Up @@ -129,7 +126,6 @@ public String getConfigXmlFileName() {

/**
* Save provider config xml.
* @throws IOException
*/
public final void save() {
try {
Expand Down
Loading

0 comments on commit 7674859

Please sign in to comment.