-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PoC: Install Java if not installed in the agent #186
base: develop
Are you sure you want to change the base?
Conversation
docs/Home.md
Outdated
@@ -110,3 +110,8 @@ Instance configurations have many options that were not listed above. A few of t | |||
access from metadata. For more info, review the service account documentation. | |||
|
|||
|
|||
# Install java if not found | |||
|
|||
By default the agents do require to have java installed, this particular flag feature will enable to install java before the provisioning happens. |
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.
s/do require/are required
s/java/Java
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 just changed a bit :)
docs/Home.md
Outdated
|
||
By default the agents do require to have java installed, this particular flag feature will enable to install java before the provisioning happens. | ||
|
||
If you want to turn on this installation strategy then you set SystemProperty `com.google.jenkins.plugins.computeengine.enableJavaInstallation=true` |
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.
Please be sure to mention the UI based configuration as well.
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.
UI was not configured for this particular use case, although I just replace it with the UI approach
return; | ||
if (ENABLE_JAVA_INSTALLATION) { | ||
logInfo(computer, listener, "Let's install java for some *nix flavours"); | ||
if (!installJava(computer, conn, logger, listener, "sudo yum install -y java-1.8.0-openjdk.x86_64")) { |
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 wonder if there might not be a Chocolatey/PS analog for Windows we could employ.
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 think so, let's see how it goes with the upcoming iterations first. I'll include a task in this PR to see whether we can support windows too.
Thanks @v1v |
88c1614
to
1c8c66d
Compare
@craigdbarber , regarding the |
@v1v Here are the logs from maven from on the test that failed:
Here is the failsafe report output from that test:
|
Actually @v1v, build 5 from our tests succeeded, but for whatever reason failed with the core jenkins build on Java 11. It doesn't make sense why, so I think it may succeed if reran. The easiest way to trigger that is probably to amend the latest commit and force push. |
I also noticed that none of the Google-provided free Linux images install a JRE by default. I settled on using Packer to publish an image to my own project: packer {
required_plugins {
googlecompute = {
version = ">= 1.1.1"
source = "github.com/hashicorp/googlecompute"
}
}
}
variable "project" {
type = string
}
variable "zone" {
type = string
}
source "googlecompute" "base" {
project_id = var.project
zone = var.zone
source_image_project_id = ["centos-cloud"]
source_image_family = "centos-stream-9"
ssh_username = "jenkins"
}
build {
sources = ["sources.googlecompute.base"]
provisioner "shell" {
inline = ["sudo dnf --assumeyes install java-11-openjdk-headless && java -version"]
}
} A feature like in this PR might be useful for experimentation but you should not use it in production—it would be too slow, and put too much load on Linux distribution package servers. |
This is a PoC to allow using the agents that are already provided in the default projects without any need to customise the Java installation in the default images for the default projects.
google-compute-engine-plugin/src/main/java/com/google/jenkins/plugins/computeengine/InstanceConfiguration.java
Lines 101 to 116 in 2e04739
A similar approach was implemented with the EC2-plugin:
Screenshots
Actions
Manual tests
I did run some tests in one of my instances:
-y
thenthe global logs said something like the below:
and the logs in the agent said the below
-y
then:Questions
A kind of similar approach can be accomplished with the Startup Script, see ->
google-compute-engine-plugin/src/test/resources/com/google/jenkins/plugins/computeengine/integration/configuration-as-code-it.yml
Line 26 in 2e04739
Do we want to enable this feature and also the script in charge of the installation? In other words, similar to the startup script but without the ssh stop/start. What do you think?
Related issues