-
Notifications
You must be signed in to change notification settings - Fork 16
Add war generator function #41
Add war generator function #41
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see this working. Eventually there probably should be a way to clean out /tmp
@kwhetstone Should we do it after the user has downloaded it, But one minor inconvenience that would cause is that if the user hits download multiple times then we wouldn't have it in temp and would have to regenerate it |
@kwhetstone I guess we can merge this once the build passes :) Edit : |
|
||
@Test | ||
public void testWarGenerationSucceeds() { | ||
WarGenerator.generateWAR("1.0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kwhetstone @LinuxSuRen When I try to test this the builder throws a huge error
java.io.IOException: Command failed with exit code 1: mvn clean package
at io.jenkins.tools.warpackager.lib.util.SystemCommandHelper.processFor(SystemCommandHelper.java:39)
at io.jenkins.tools.warpackager.lib.util.MavenHelper.run(MavenHelper.java:66)
at io.jenkins.tools.warpackager.lib.util.MavenHelper.run(MavenHelper.java:46)
at io.jenkins.tools.warpackager.lib.impl.Builder.build(Builder.java:146)
at com.org.jenkins.custom.jenkins.distribution.service.generators.WarGenerator.generateWAR(WarGenerator.java:24)
at com.org.jenkins.custom.jenkins.distribution.service.generators.WarGeneratorTest.testWarGenerationSucceeds(WarGeneratorTest.java:9)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open issue in Custom War Packager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why you want to keep tmp/prebuild/pom.xml
.
final File configPath = util.getFileFromResources(PACKAGER_CONFIG_YAML); | ||
try { | ||
cfg = Config.loadConfig(configPath); | ||
cfg.buildSettings.setTmpDir(new File(DEFAULT_TMP_DIR_NAME)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get a temporary directory by the following code:
System.getProperty("java.io.tmpdir")
Furthermore, a user can give it a different value by passing a path. For example: java -Djava.io.tmpdir=/path/to/tmpdir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes made the change 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@LinuxSuRen The test is throwing errors.
Have a look at the code here: https://github.com/jenkinsci/custom-war-packager/blob/3aa29ed5432051198b9de410223732cc21843f36/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/impl/Builder.java#L78 |
It might be caused by some restriction OS environments. |
Maybe that is why it asks for a |
I think that you can pass it another directory. It is already configrable now. |
Like what ? Because it would anyway be created in the project structure, so does it matter if I pass temp again ? |
Or you can get the temporary directory by reading a config file. |
I do not think it would make a difference since the value in the config file would be static. It is a web service so there would be no way to change it |
If using Java you can write a temp file using Files. I think all you have to do here is call delete on the file object at the end of all this. |
…-distribution-service into 14_custom_war_generation
2b5cfbd
to
838f548
Compare
@sladyn98 Looks like there's an error while trying to build the job. The reason the build failed was looking for test reports and it couldn't find it. You can configure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome passing build! Let's get this merged in!
This PR adds the war generator function using the custom war packager library. It pulls in the packager config from the resources folder.
The Jenkinsfile Needs to be fixed before this can be merged in
Closes #14