@@ -18,10 +18,10 @@ public abstract class DeploymentManager extends Thread {
1818
1919 public static JSch jsch = new JSch ();
2020
21- private List <String > previousArtifacts ;
21+ private List <Integer > previousReleases ;
2222
2323 public DeploymentManager () {
24- this .previousArtifacts = new ArrayList <>();
24+ this .previousReleases = new ArrayList <>();
2525
2626 start ();
2727 }
@@ -33,25 +33,23 @@ public void run() {
3333 while (true ){
3434 List <Artifact > artifacts = getArtifacts ();
3535
36- if (!previousArtifacts .isEmpty ()){
37- artifacts .stream ().filter (artifact -> !previousArtifacts .contains (artifact .getReleaseTag ()))
36+ if (!previousReleases .isEmpty ()){
37+ artifacts .stream ().filter (artifact -> !previousReleases .contains (artifact .getRelease (). getId ()))
3838 .forEach (artifact -> {
39- System .out .println ("New Artifact found" );
40-
4139 Project project = artifact .getRelease ().getProject ();
4240
4341 if (artifact .getAssets ().length == 0 ){
4442 System .out .println ("[" +project .getName ()+"] The Release [" +artifact .getReleaseTag ()+"] does not contain any assets, skipping deployment" );
4543 return ;
4644 }
4745
48- for (Deployment deployment : project .getDeployments ()){
49- if (!deployment .isEnabled ()) continue ;
46+ for (Deployment deployment : project .getDeployments ()) {
47+ if (!deployment .isEnabled ()) continue ;
5048
5149 Remote remote = deployment .getRemote ();
5250
5351 try {
54- java . util . Properties config = new java . util . Properties ();
52+ Properties config = new Properties ();
5553 config .put ("StrictHostKeyChecking" , "no" );
5654
5755 Session session = jsch .getSession (remote .getUsername (), remote .getHostname (), remote .getPort ());
@@ -63,13 +61,13 @@ public void run() {
6361 sftp .connect ();
6462 sftp .cd (deployment .getPath ());
6563
66- for (File asset : artifact .getAssets ()){
64+ for (File asset : artifact .getAssets ()) {
6765 sftp .put (new FileInputStream (asset ), asset .getName (), ChannelSftp .OVERWRITE );
6866 }
6967
7068 sftp .exit ();
7169
72- for (String command : deployment .getCommands ()){
70+ for (String command : deployment .getCommands ()) {
7371 ChannelExec channel = (ChannelExec ) session .openChannel ("exec" );
7472 channel .setCommand (command );
7573 channel .connect ();
@@ -84,16 +82,16 @@ public void run() {
8482 }
8583
8684 session .disconnect ();
87- System .out .println ("[" + project .getName ()+ "] Deployment of release [" + artifact .getReleaseTag ()+ "] to remote [" + remote .getHostname ()+ "] was successful" );
85+ System .out .println ("[" + project .getName () + "] Deployment of release [" + artifact .getReleaseTag () + "] to remote [" + remote .getHostname () + "] was successful" );
8886 } catch (JSchException | SftpException | IOException e ) {
89- System .out .println ("[" + project .getName ()+ "] Error while deploying release [" + artifact .getReleaseTag ()+ "] to [" + remote .getHostname ()+ "]" );
87+ System .out .println ("[" + project .getName () + "] Error while deploying release [" + artifact .getReleaseTag () + "] to [" + remote .getHostname () + "]" );
9088 System .out .println (e .getMessage ());
9189 }
9290 }
9391 });
9492 }
9593
96- this .previousArtifacts = artifacts .stream ().map (Artifact :: getReleaseTag ).collect (Collectors .toList ());
94+ this .previousReleases = artifacts .stream ().map (a -> a . getRelease (). getId () ).collect (Collectors .toList ());
9795
9896 try {
9997 sleep (DELAY );
0 commit comments