forked from jenkinsci/custom-distribution-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add War download feature (jenkinsci#68)
* Add War download feature * Added code suggestions * Committed suggestions * Fixed arguments * Removed test and added war download funtion to frontend * Trigger Build
- Loading branch information
Sladyn
committed
Jul 22, 2020
1 parent
0072942
commit e89660b
Showing
8 changed files
with
68 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 14 additions & 16 deletions
30
...ain/java/com/org/jenkins/custom/jenkins/distribution/service/generators/WarGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,33 @@ | ||
package com.org.jenkins.custom.jenkins.distribution.service.generators; | ||
|
||
import com.org.jenkins.custom.jenkins.distribution.service.util.Util; | ||
import io.jenkins.tools.warpackager.lib.config.Config; | ||
import io.jenkins.tools.warpackager.lib.impl.Builder; | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.logging.Logger; | ||
|
||
public class WarGenerator { | ||
|
||
private static Util util = new Util(); | ||
|
||
private static final String PACKAGER_CONFIG_YAML = "packager-config.yml"; | ||
private final static Logger LOGGER = Logger.getLogger(WarGenerator.class.getName()); | ||
private static final String TEMP_PREFIX = "CDS"; | ||
|
||
public static void generateWAR(String versionName) { | ||
|
||
public static File generateWAR(String versionName, String configuration) throws Exception { | ||
LOGGER.info("Generating War File"); | ||
final Config cfg; | ||
Path tempDirWithPrefix = null; | ||
try { | ||
tempDirWithPrefix = Files.createTempDirectory(TEMP_PREFIX); | ||
final File configPath = util.getFileFromResources(PACKAGER_CONFIG_YAML); | ||
cfg = Config.loadConfig(configPath); | ||
Path tempDirWithPrefix = Files.createTempDirectory(TEMP_PREFIX); | ||
File packagerConfigFile = File.createTempFile("packager-config", ".yml"); | ||
byte[] buf = configuration.getBytes(); | ||
Files.write(packagerConfigFile.toPath(), buf); | ||
cfg = Config.loadConfig(packagerConfigFile); | ||
cfg.buildSettings.setTmpDir(tempDirWithPrefix.toFile()); | ||
cfg.buildSettings.setVersion(versionName); | ||
cfg.buildSettings.setInstallArtifacts(true); | ||
new Builder(cfg).build(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} finally { | ||
util.cleanupTempDirectory(tempDirWithPrefix.toFile()); | ||
} | ||
LOGGER.info("Cleaning up temporary directory"); | ||
packagerConfigFile.deleteOnExit(); | ||
return cfg.getOutputWar(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
...java/com/org/jenkins/custom/jenkins/distribution/service/generators/WarGeneratorTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters