Skip to content

Commit

Permalink
Merge branch 'master' into JENKINS-50969
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-nenashev committed May 4, 2018
2 parents b3c5c40 + a4a1355 commit 541c31f
Show file tree
Hide file tree
Showing 54 changed files with 314 additions and 147 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
target
.flattened-pom.xml
work

# IntelliJ project files
Expand Down
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
@@ -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</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.0-alpha-3</version>
</extension>
</extensions>
1 change: 1 addition & 0 deletions .mvn/maven.config
@@ -0,0 +1 @@
-Pmight-produce-incrementals
33 changes: 14 additions & 19 deletions Jenkinsfile
Expand Up @@ -30,6 +30,9 @@ for(i = 0; i < buildTypes.size(); i++) {
checkout scm
}

def changelistF = "${pwd tmp: true}/changelist"
def m2repo = "${pwd tmp: true}/m2repo"

// Now run the actual build.
stage("${buildType} Build / Test") {
timeout(time: 180, unit: 'MINUTES') {
Expand All @@ -39,7 +42,7 @@ for(i = 0; i < buildTypes.size(); i++) {
"MAVEN_OPTS=-Xmx1536m -Xms512m"]) {
// Actually run Maven!
// -Dmaven.repo.local=… tells Maven to create a subdir in the temporary directory for the local Maven repository
def mvnCmd = "mvn -Pdebug -U javadoc:javadoc clean install ${runTests ? '-Dmaven.test.failure.ignore' : '-DskipTests'} -V -B -Dmaven.repo.local=${pwd tmp: true}/m2repo -s settings-azure.xml -e"
def mvnCmd = "mvn -Pdebug -U -Dset.changelist help:evaluate -Dexpression=changelist -Doutput=$changelistF clean install ${runTests ? '-Dmaven.test.failure.ignore' : '-DskipTests'} -V -B -Dmaven.repo.local=$m2repo -s settings-azure.xml -e"
if(isUnix()) {
sh mvnCmd
sh 'test `git status --short | tee /dev/stderr | wc --bytes` -eq 0'
Expand All @@ -52,14 +55,17 @@ for(i = 0; i < buildTypes.size(); i++) {

// Once we've built, archive the artifacts and the test results.
stage("${buildType} Publishing") {
def files = findFiles(glob: '**/target/*.jar, **/target/*.war, **/target/*.hpi')
renameFiles(files, buildType.toLowerCase())

archiveArtifacts artifacts: '**/target/*.jar, **/target/*.war, **/target/*.hpi',
fingerprint: true
if (runTests) {
junit healthScaleFactor: 20.0, testResults: '*/target/surefire-reports/*.xml'
}
if (buildType == 'Linux') {
def changelist = readFile(changelistF)
dir(m2repo) {
archiveArtifacts artifacts: "**/*$changelist/*$changelist*",
excludes: '**/*.lastUpdated,**/jenkins-test/',
fingerprint: true
}
}
}
}
}
Expand All @@ -76,7 +82,7 @@ builds.ath = {
checkout scm
withMavenEnv(["JAVA_OPTS=-Xmx1536m -Xms512m",
"MAVEN_OPTS=-Xmx1536m -Xms512m"]) {
sh "mvn -DskipTests -am -pl war package -Dmaven.repo.local=${pwd tmp: true}/m2repo -s settings-azure.xml"
sh "mvn --batch-mode --show-version -DskipTests -am -pl war package -Dmaven.repo.local=${pwd tmp: true}/m2repo -s settings-azure.xml"
}
dir("war/target") {
fileUri = "file://" + pwd() + "/jenkins.war"
Expand All @@ -91,6 +97,7 @@ builds.ath = {

builds.failFast = failFast
parallel builds
infra.maybePublishIncrementals()

// This method sets up the Maven and JDK tools, puts them in the environment along
// with whatever other arbitrary environment variables we passed in, and runs the
Expand All @@ -115,15 +122,3 @@ void withMavenEnv(List envVars = [], def body) {
body.call()
}
}

void renameFiles(def files, String prefix) {
for(i = 0; i < files.length; i++) {
def newPath = files[i].path.replace(files[i].name, "${prefix}-${files[i].name}")
def rename = "${files[i].path} ${newPath}"
if(isUnix()) {
sh "mv ${rename}"
} else {
bat "move ${rename}"
}
}
}
2 changes: 1 addition & 1 deletion cli/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-parent</artifactId>
<version>2.119-SNAPSHOT</version>
<version>${revision}${changelist}</version>
</parent>

<artifactId>cli</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Expand Up @@ -29,7 +29,7 @@ THE SOFTWARE.
<parent>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-parent</artifactId>
<version>2.119-SNAPSHOT</version>
<version>${revision}${changelist}</version>
</parent>

<artifactId>jenkins-core</artifactId>
Expand Down
18 changes: 16 additions & 2 deletions core/src/main/java/hudson/ExtensionList.java
Expand Up @@ -145,15 +145,29 @@ public void addListener(@Nonnull ExtensionListListener listener) {
* Looks for the extension instance of the given type (subclasses excluded),
* or return null.
*/
public @CheckForNull <U extends T> U get(Class<U> type) {
public @CheckForNull <U extends T> U get(@Nonnull Class<U> type) {
for (T ext : this)
if(ext.getClass()==type)
return type.cast(ext);
return null;
}

/**
* Looks for the extension instance of the given type (subclasses excluded),
* or throws an IllegalStateException.
*
* Meant to simplify call inside @Extension annotated class to retrieve their own instance.
*/
public @Nonnull <U extends T> U getInstance(@Nonnull Class<U> type) throws IllegalStateException {
for (T ext : this)
if(ext.getClass()==type)
return type.cast(ext);

throw new IllegalStateException("The class " + type.getName() + " was not found, potentially not yet loaded");
}

@Override
public Iterator<T> iterator() {
public @Nonnull Iterator<T> iterator() {
// we need to intercept mutation, so for now don't allow Iterator.remove
return new AdaptedIterator<ExtensionComponent<T>,T>(Iterators.readOnly(ensureLoaded().iterator())) {
protected T adapt(ExtensionComponent<T> item) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/FilePath.java
Expand Up @@ -907,7 +907,7 @@ public void copyFrom(URL url) throws IOException, InterruptedException {
/**
* Copies the content of a URL to a remote file.
* Unlike {@link #copyFrom} this will not transfer content over a Remoting channel.
* @since FIXME
* @since 2.119
*/
@Restricted(Beta.class)
public void copyFromRemotely(URL url) throws IOException, InterruptedException {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/model/AbstractItem.java
Expand Up @@ -240,7 +240,7 @@ protected void doSetName(String name) {
* @return whether {@link #name} can be modified by a user
* @see #checkRename
* @see #renameTo
* @since FIXME
* @since 2.110
*/
public boolean isNameEditable() {
return false;
Expand Down Expand Up @@ -335,7 +335,7 @@ private void checkIfNameIsUsed(@Nonnull String newName) throws Failure {
*
* @param newName the new name for the item
* @throws Failure if the rename should be blocked
* @since FIXME
* @since 2.110
* @see Job#checkRename
*/
protected void checkRename(@Nonnull String newName) throws Failure {
Expand Down
Expand Up @@ -61,7 +61,7 @@ private ChoiceParameterDefinition(String name, List<String> choices, String defa
* @param name parameter name
* @param description parameter description
*
* @since TODO
* @since 2.112
*/
@DataBoundConstructor
@Restricted(NoExternalUse.class) // there are specific constructors with String and List arguments for 'choices'
Expand All @@ -82,7 +82,7 @@ public ChoiceParameterDefinition(String name, String description) {
*
* @param choices String or Collection representing this parameter definition's possible values.
*
* @since TODO
* @since 2.112
*
*/
@DataBoundSetter
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/Descriptor.java
Expand Up @@ -821,7 +821,7 @@ public String getGlobalConfigPage() {
*
* @since 2.0, used to be in {@link GlobalConfiguration} before that.
*/
public GlobalConfigurationCategory getCategory() {
public @Nonnull GlobalConfigurationCategory getCategory() {
return GlobalConfigurationCategory.get(GlobalConfigurationCategory.Unclassified.class);
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/Run.java
Expand Up @@ -1133,7 +1133,7 @@ public SerializableArtifactList call() throws IOException {

private static int addArtifacts(@Nonnull VirtualFile dir,
@Nonnull String path, @Nonnull String pathHref,
@Nonnull SerializableArtifactList r, @Nonnull SerializableArtifact parent, int upTo) throws IOException {
@Nonnull SerializableArtifactList r, @CheckForNull SerializableArtifact parent, int upTo) throws IOException {
VirtualFile[] kids = dir.list();
Arrays.sort(kids);

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/security/ACL.java
Expand Up @@ -100,7 +100,7 @@ public final boolean hasPermission(@Nonnull Permission p) {
* Creates a simple {@link ACL} implementation based on a “single-abstract-method” easily implemented via lambda syntax.
* @param impl the implementation of {@link ACL#hasPermission(Authentication, Permission)}
* @return an adapter to that lambda
* @since FIXME
* @since 2.105
*/
public static ACL lambda(final BiFunction<Authentication, Permission, Boolean> impl) {
return new ACL() {
Expand Down
Expand Up @@ -31,6 +31,8 @@
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.StaplerRequest;

import javax.annotation.Nonnull;

/**
* Show the crumb configuration to the system config page.
*
Expand All @@ -39,14 +41,14 @@
@Extension(ordinal=195) @Symbol("crumb") // immediately after the security setting
public class GlobalCrumbIssuerConfiguration extends GlobalConfiguration {
@Override
public GlobalConfigurationCategory getCategory() {
public @Nonnull GlobalConfigurationCategory getCategory() {
return GlobalConfigurationCategory.get(GlobalConfigurationCategory.Security.class);
}

@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
// for compatibility reasons, the actual value is stored in Jenkins
Jenkins j = Jenkins.getInstance();
Jenkins j = Jenkins.get();
if (json.has("csrf")) {
JSONObject csrf = json.getJSONObject("csrf");
j.setCrumbIssuer(CrumbIssuer.all().newInstanceFromRadioList(csrf, "issuer"));
Expand Down
8 changes: 5 additions & 3 deletions core/src/main/java/hudson/tools/ToolDescriptor.java
Expand Up @@ -44,6 +44,8 @@
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

import javax.annotation.Nonnull;

/**
* {@link Descriptor} for {@link ToolInstallation}.
*
Expand All @@ -57,7 +59,7 @@ public abstract class ToolDescriptor<T extends ToolInstallation> extends Descrip
protected ToolDescriptor() { }

/**
* @since FIXME
* @since 2.102
*/
protected ToolDescriptor(Class<T> clazz) {
super(clazz);
Expand Down Expand Up @@ -109,12 +111,12 @@ public void setInstallations(T... installations) {
* Lists up {@link ToolPropertyDescriptor}s that are applicable to this {@link ToolInstallation}.
*/
public List<ToolPropertyDescriptor> getPropertyDescriptors() {
return PropertyDescriptor.<ToolPropertyDescriptor, ToolInstallation>for_(ToolProperty.all(), clazz);
return PropertyDescriptor.for_(ToolProperty.all(), clazz);
}


@Override
public GlobalConfigurationCategory getCategory() {
public @Nonnull GlobalConfigurationCategory getCategory() {
return GlobalConfigurationCategory.get(ToolConfigurationCategory.class);
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/triggers/SafeTimerTask.java
Expand Up @@ -86,7 +86,7 @@ public final void run() {
* @see AsyncAperiodicWork#getLogFile()
* @see AsyncPeriodicWork#getLogFile()
* @return the path where the logs should be put.
* @since TODO
* @since 2.114
*/
public static File getLogsRoot() {
String tagsLogsPath = SystemProperties.getString(LOGS_ROOT_PATH_PROPERTY);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/util/FormValidation.java
Expand Up @@ -400,7 +400,7 @@ public static FormValidation validateNonNegativeInteger(String value) {
* @param lower the lower bound (inclusive)
* @param upper the upper bound (inclusive)
*
* @since TODO
* @since 2.104
*/
public static FormValidation validateIntegerInRange(String value, int lower, int upper) {
try {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/util/HttpResponses.java
Expand Up @@ -118,7 +118,7 @@ public static HttpResponse errorJSON(@Nonnull String message, @Nonnull Map<?,?>
* @param data The data.
* @return {@code this} object.
*
* @since TODO
* @since 2.115
*/
public static HttpResponse errorJSON(@Nonnull String message, @Nonnull JSONObject data) {
return new JSONObjectResponse(data).error(message);
Expand All @@ -130,7 +130,7 @@ public static HttpResponse errorJSON(@Nonnull String message, @Nonnull JSONObjec
* @param data The data.
* @return {@code this} object.
*
* @since TODO
* @since 2.115
*/
public static HttpResponse errorJSON(@Nonnull String message, @Nonnull JSONArray data) {
return new JSONObjectResponse(data).error(message);
Expand Down

0 comments on commit 541c31f

Please sign in to comment.