161
161
import org .apache .tools .ant .BuildException ;
162
162
import org .apache .tools .ant .Project ;
163
163
import org .apache .tools .ant .taskdefs .Chmod ;
164
- import org .kohsuke .accmod .Restricted ;
165
- import org .kohsuke .accmod .restrictions .NoExternalUse ;
166
164
import org .kohsuke .stapler .AncestorInPath ;
167
165
import org .kohsuke .stapler .DataBoundConstructor ;
168
166
import org .kohsuke .stapler .QueryParameter ;
192
190
import com .trilead .ssh2 .DebugLogger ;
193
191
import com .trilead .ssh2 .SCPClient ;
194
192
import com .trilead .ssh2 .crypto .Base64 ;
193
+ import static java .util .stream .Collectors .toList ;
195
194
import javax .annotation .Nonnull ;
196
195
import jenkins .MasterToSlaveFileCallable ;
197
196
import jenkins .security .Roles ;
198
197
import jenkins .security .SlaveToMasterCallable ;
198
+ import org .apache .commons .collections .CollectionUtils ;
199
199
import org .jenkinsci .remoting .RoleChecker ;
200
200
import org .kohsuke .stapler .interceptor .RequirePOST ;
201
201
@@ -882,18 +882,18 @@ public boolean requiresWorkspaceForPolling() {
882
882
}
883
883
}
884
884
885
+ List <SvnInfoP > pList = workspace .act (new BuildRevisionMapTask (build , this , listener , externalsForAll , env ));
886
+ List <SvnInfo > revList = pList .stream ().map (svnInfoP -> svnInfoP .info ).collect (toList ());
887
+
885
888
// write out the revision file
886
889
try (PrintWriter w = new PrintWriter (new FileOutputStream (getRevisionFile (build )))) {
887
- List <SvnInfoP > pList = workspace .act (new BuildRevisionMapTask (build , this , listener , externalsForAll , env ));
888
- List <SvnInfo > revList = new ArrayList <SvnInfo >(pList .size ());
889
890
for (SvnInfoP p : pList ) {
890
- if (p .pinned )
891
+ if (p .pinned ) {
891
892
w .println ( p .info .url +'/' + p .info .revision + "::p" );
892
- else
893
+ } else {
893
894
w .println ( p .info .url +'/' + p .info .revision );
894
- revList . add ( p . info );
895
+ }
895
896
}
896
- build .addAction (new SubversionTagAction (build ,revList ));
897
897
}
898
898
899
899
// write out the externals info
@@ -903,8 +903,16 @@ public boolean requiresWorkspaceForPolling() {
903
903
projectExternalsCache .put (build .getParent (), externalsForAll );
904
904
}
905
905
906
- if (changelogFile != null ) {
907
- calcChangeLog (build , workspace , changelogFile , baseline , listener , externalsMap , env );
906
+ // check if a SubversionTagAction with the same scm changes has been already added in a previous checkout/update in the build
907
+ boolean scmChangesAlreadyProcessed = build .getActions (SubversionTagAction .class ).stream ()
908
+ .anyMatch (existingTagAction -> CollectionUtils .isEqualCollection (existingTagAction .getTags ().keySet (), revList ));
909
+
910
+ // Don't add the tag and changelog if no changelog was requested or we've already processed this scm changes before
911
+ if (changelogFile != null && !scmChangesAlreadyProcessed ) {
912
+ // add the tag action
913
+ build .addAction (new SubversionTagAction (build ,revList ));
914
+ // write out the changelog file
915
+ calcChangeLog (build , workspace , changelogFile , baseline , listener , externalsMap , env );
908
916
}
909
917
}
910
918
0 commit comments