Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Do we need to add environment variables to Jenkins? #528

Open
ecormaksin opened this issue Jul 3, 2021 · 0 comments
Open

Do we need to add environment variables to Jenkins? #528

ecormaksin opened this issue Jul 3, 2021 · 0 comments

Comments

@ecormaksin
Copy link

About this page, I followed the instructions along the way, but build failed.

The console output is like below.

I think that the environment variables JAVA_HOME (value: /opt/java/openjdk), PATH (value: /opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin) need to be added to the Jenkins System Configuration.

Started by user jenkins
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/ci-test
The recommended git tool is: NONE
No credentials specified
 > git rev-parse --resolve-git-dir /var/jenkins_home/workspace/ci-test/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/fabianenardon/mongo-docker-demo.git # timeout=10
Fetching upstream changes from https://github.com/fabianenardon/mongo-docker-demo.git
 > git --version # timeout=10
 > git --version # 'git version 2.20.1'
 > git fetch --tags --force --progress -- https://github.com/fabianenardon/mongo-docker-demo.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision dfb83068c27c62f0268613ee02ab89204613b6f7 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f dfb83068c27c62f0268613ee02ab89204613b6f7 # timeout=10
Commit message: "Added testing instructions"
 > git rev-list --no-walk dfb83068c27c62f0268613ee02ab89204613b6f7 # timeout=10
[ci-test] $ /bin/sh -xe /tmp/jenkins8286753912285544023.sh
+ cd sample
+ sudo -E /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/maven/bin/mvn clean install -Papp-docker-image
Error: JAVA_HOME is not defined correctly.
  We cannot execute /docker-java-home/bin/java
Build step 'Execute shell' marked build as failure
[PostBuildScript] - [INFO] Executing post build scripts.
[ci-test] $ /bin/sh -xe /tmp/jenkins152989329278895156.sh
+ cd sample
+ sudo -E docker-compose -p app-4 --file src/test/resources/docker-compose.yml down
Removing network app4_default
Network app4_default not found.
Finished: FAILURE
ecormaksin added a commit to ecormaksin/labs that referenced this issue Jul 3, 2021
The current settings (scripts) did not work in my environment. The commands are executed as sudo, then somewhat environment vriables aren't passed. So it seems to be added `-E` option. And according to jdk version change, jvm option `--add-opens=java.base/java.lang=ALL-UNNAMED` also needs to be added.

Additionally, the environment variables `JAVA_HOME`, `PATH` need to be added to Jenkins System Configuraion, as I issued docker#528.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant