I am trying to set up Jenkins HA with one active and one cold standby node on Ubuntu-14.
I was looking at this question:
How to setup Jenkins with HA?
I see that I just need to replicate the contents of /var/lib/jenkins, which is my $JENKINS_HOME.
#ls -alh /var/lib/jenkins
drwxrwxr-x 3 jenkins jenkins 4.0K Oct 16 19:45 .bundle
drwxr-xr-x 3 jenkins jenkins 4.0K Oct 26 14:54 .cache
-rw-r--r-- 1 jenkins jenkins 2.4K Oct 24 21:09 config.xml
-rw-r--r-- 1 jenkins jenkins 950 Oct 16 20:34 credentials.xml
drwxr-xr-x 3 jenkins jenkins 4.0K Oct 16 19:53 .groovy
-rw-r--r-- 1 jenkins jenkins 159 Oct 16 20:02 hudson.model.UpdateCenter.xml
-rw-r--r-- 1 jenkins jenkins 370 Oct 16 19:52 hudson.plugins.git.GitTool.xml
-rw------- 1 jenkins jenkins 1.7K Oct 16 19:40 identity.key.enc
drwxr-xr-x 3 jenkins jenkins 4.0K Oct 16 19:40 .java
-rw-r--r-- 1 jenkins jenkins 6 Oct 16 20:02 jenkins.install.InstallUtil.lastExecVersion
-rw-r--r-- 1 jenkins jenkins 6 Oct 16 19:54 jenkins.install.UpgradeWizard.state
drwxr-xr-x 5 jenkins jenkins 4.0K Oct 26 14:43 jobs
drwxr-xr-x 3 jenkins jenkins 4.0K Oct 16 19:40 logs
-rw-r--r-- 1 jenkins jenkins 907 Oct 16 20:02 nodeMonitors.xml
drwxr-xr-x 2 jenkins jenkins 4.0K Oct 16 19:40 nodes
-rw-r--r-- 1 jenkins jenkins 56 Nov 4 19:57 .owner
drwxr-xr-x 81 jenkins jenkins 12K Oct 16 19:59 plugins
drwxr-xr-x 5 jenkins jenkins 4.0K Oct 16 20:43 .puppetlabs
-rw-r--r-- 1 jenkins jenkins 129 Oct 16 20:02 queue.xml.bak
-rw-r--r-- 1 jenkins jenkins 64 Oct 16 19:40 secret.key
-rw-r--r-- 1 jenkins jenkins 0 Oct 16 19:40 secret.key.not-so-secret
drwx------ 4 jenkins jenkins 4.0K Oct 16 20:43 secrets
drwxr-xr-x 2 jenkins jenkins 4.0K Nov 4 20:02 updates
drwxr-xr-x 2 jenkins jenkins 4.0K Oct 16 19:40 userContent
drwxr-xr-x 4 jenkins jenkins 4.0K Oct 17 13:09 users
drwxr-xr-x 2 jenkins jenkins 4.0K Oct 16 19:53 workflow-libs
drwxr-xr-x 2 jenkins jenkins 4.0K Oct 28 15:26 workspace
Should I replicate all of the above items? If not, then which ones should I sync? Any gotchas or anything else I need to know?
Thanks!
I have tested this scenario and have chosen to replicate everything with the following exclusions. Initial testing after this seems to indicate success with plugins, jobs, credentials etc.
rsync -e "ssh -o StrictHostKeyChecking=no" -rvh --delete --exclude '.bash_history' \
--exclude 'logs' --exclude '.ssh' --exclude '.viminfo' \
--exclude '.cache' ./ jenkins#JENKINS-STANDBY-NODE:/var/lib/jenkins/
Related
I'm having a pipeline in azure devops that is supposed to be executed on a linux agent.
One task in this pipeline is to run parasoft static code analysis.
We are using a docker container that includes parasoft and which is executin g a bash script to compile our sources and run sca.
My issue is, that on the next run of the pipeline, I'll get an error because it is impossible to checkout the code from git. The reason for that is, during the build with cmake some directories will be created as root.
Here is the related task of the pipeline
- task: Bash#3
displayName: "Run sca"
inputs:
targetType: 'inline'
script: |
docker run -t -v "$(System.DefaultWorkingDirectory):/host" --platform=linux/amd64 -w /host/ containerregistry.azurecr.io/diag/parasoft:2.8.0 /bin/bash -c "\
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug && \
cpptestcli -localsettings /host/parasoft.properties -config \"someconfig\" \
-bdf /host/build/compile_commands.json -report /host/sca-report -include \"host/src/**/*.cpp\" \
"
Here is the content of the folder after the docker run
completed:agent#host:~/az_agent/_work/1/s$ ll
total 100
drwxr-xr-x 16 agent agents 4096 Dez 23 16:14 ./
drwxr-xr-x 6 agent agents 4096 Dez 23 15:37 ../
drwxr-xr-x 7 root root 4096 Dez 23 15:38 build/
drwxr-xr-x 2 agent agents 4096 Dez 23 15:31 cmake/
-rw-r--r-- 1 agent agents 994 Dez 23 15:31 CMakeLists.txt
-rw-r--r-- 1 root root 4605 Dez 23 15:42 c++test_static_problems.txt
drwxr-xr-x 7 agent agents 4096 Dez 23 15:31 diagmaster/
drwxr-xr-x 5 agent agents 4096 Dez 22 12:47 doc/
drwxr-xr-x 2 agent agents 4096 Dez 23 15:31 docker/
drwxr-xr-x 5 agent agents 4096 Dez 23 15:31 etc/
drwxr-xr-x 6 agent agents 4096 Dez 23 15:31 gen/
drwxr-xr-x 8 agent agents 4096 Dez 23 15:37 .git/
-rw-r--r-- 1 agent agents 70 Dez 23 15:31 .gitignore
-rw-r--r-- 1 agent agents 1478 Dez 23 15:31 parasoft.properties
drwxr-xr-x 4 root root 4096 Dez 23 15:38 parasoft_workspace/
drwxr-xr-x 2 agent agents 4096 Dez 23 15:37 pipelines/
-rw-r--r-- 1 agent agents 723 Dez 23 15:31 README.md
drwxr-xr-x 5 agent agents 4096 Dez 23 15:31 src/
-rwxrwxrwx 1 agent agents 640 Dez 23 16:14 test.sh*
drwxr-xr-x 3 agent agents 4096 Dez 23 15:31 utils/
If I change the ownership manually e.g. by this command the next execution of the pipeline works without issues.
sudo chown -R --reference=cmake *
Of sourse I don't want to run this command in my pipeline.
From your description, the issue now focuses on the error 'UnauthorizedAccessException due to pipeline created folders as root'.
You could try to use things like this to give permission to the run agent.
chown -R agent:agents *
Then the issue is supposed to resolve.
I have a cloudbuild.yaml file that looks like this:
steps:
- name: 'gcr.io/cloud-builders/gsutil'
args: [ "-m", "rsync", "-r", "gs://${_BUCKET}/maven-repository", "/cache/.m2" ]
volumes:
- path: '/cache/.m2'
name: 'm2_cache'
- name: docker/compose:debian-1.29.2
entrypoint: bash
args:
- -c
- |
./test.sh
volumes:
- path: '/cache/.m2'
name: 'm2_cache'
timeout: 2700s
substitutions:
_BUCKET: 'my-bucket'
In the first step we download our maven settings.xml file from GCS. This file is crucial for subsequent build steps since it contain the username/password to our Artifact Registry Maven repository (I've simplified this example as we don't actually store the credential in the settings.xml as plain text). Without these credentials, our Maven build won't run. Normally the script that we call in the second step starts several docker containers and then run our maven tests. But I've replaced it with test.sh to easier show what the problem is. The test.sh file is shown below:
#!/bin/bash
echo "### [Host] Contents in /cache/.m2"
ls -la /cache/.m2
mkdir ~/test
echo "Johan" > ~/test/ikk.txt
echo "### [Host] Contents in ~/test"
ls -la ~/test
docker run --rm -v /cache/.m2:/cache/.m2 -v ~/test:/root/test -w /usr/src/somewhere ubuntu bash -c 'echo "### [Docker] Contents in /cache/.m2" && ls -la /cache/.m2 && echo "### [Docker] Contents in /root/test" && ls -la /root/test'
I.e. we try to mount two volumes to the ubuntu container that we start in the test.sh file. I list the contents in two directors both outside (### [Host]) and inside (### [Docker]) the ubuntu container. Here's the relevant output of running this in cloud build:
### [Host] Contents in /cache/.m2
total 16
drwxr-xr-x 2 root root 4096 Sep 15 08:55 .
drwxr-xr-x 3 root root 4096 Sep 15 08:55 ..
-rw-r--r-- 1 root root 8063 Sep 13 11:03 settings.xml
### [Host] Contents in ~/test
total 12
drwxr-xr-x 2 root root 4096 Sep 15 08:55 .
drwxr-xr-x 6 root root 4096 Sep 15 08:55 ..
-rw-r--r-- 1 root root 6 Sep 15 08:55 ikk.txt
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
Digest: sha256:20fa2d7bb4de7723f542be5923b06c4d704370f0390e4ae9e1c833c8785644c1
Status: Downloaded newer image for ubuntu:latest
### [Docker] Contents in /cache/.m2
total 8
drwxr-xr-x 2 root root 4096 Sep 15 08:55 .
drwxr-xr-x 3 root root 4096 Sep 15 08:55 ..
### [Docker] Contents in /root/test
total 8
drwxr-xr-x 2 root root 4096 Sep 15 08:55 .
drwx------ 1 root root 4096 Sep 15 08:55 ..
As you can see, the volume mounts doesn't seem to work when I run the ubuntu container from the test.sh file in cloud build (since the contents of /root/test and /cache/.m2 are empty).
Running the test.sh locally on my machine yields the expected outcome:
### [Host] Contents in /cache/.m2
total 40
drwxr-xr-x 7 johan staff 224 Mar 15 2022 .
drwxr-x---+ 87 johan staff 2784 Sep 15 10:58 ..
-rw-r--r-- 1 johan staff 2344 Sep 14 11:37 copy_reference_file.log
drwxr-xr-x 221 johan staff 7072 Sep 14 10:52 repository
-rw-r--r-- 1 johan staff 327 Nov 24 2021 settings-docker.xml
-rw-r--r--# 1 johan staff 9842 Mar 15 2022 settings.xml
drwxr-xr-x 3 johan staff 96 Nov 19 2021 wrapper
### [Host] Contents in ~/test
total 8
drwxr-xr-x# 3 johan staff 96 Sep 15 10:53 .
drwxr-xr-x# 135 johan staff 4320 Sep 15 10:49 ..
-rw-r--r-- 1 johan staff 6 Sep 15 10:58 ikk.txt
### [Docker] Contents in /cache/.m2
total 24
drwxr-xr-x 7 root root 224 Mar 15 2022 .
drwxr-xr-x 3 root root 4096 Sep 15 08:58 ..
-rw-r--r-- 1 root root 2344 Sep 14 09:37 copy_reference_file.log
drwxr-xr-x 221 root root 7072 Sep 14 08:52 repository
-rw-r--r-- 1 root root 327 Nov 24 2021 settings-docker.xml
-rw-r--r-- 1 root root 9842 Mar 15 2022 settings.xml
drwxr-xr-x 3 root root 96 Nov 19 2021 wrapper
### [Docker] Contents in /root/test
total 8
drwxr-xr-x 3 root root 96 Sep 15 08:53 .
drwx------ 1 root root 4096 Sep 15 08:58 ..
-rw-r--r-- 1 root root 6 Sep 15 08:58 ikk.txt
Here you can see that the volumes are mounted correctly and I can access the files inside the ubuntu container.
How can I mount volumes inside a container in cloud build?
jenkins home (JENKINS_HOME) directory contains ".java" with the following contents.
What is the purpose, who creates this?
[jenkins#jenkins data]$ ls -R -la .java
.java:
total 12
drwxr-xr-x 4 jenkins jenkins 47 Sep 24 2021 .
drwxr-xr-x 32 jenkins jenkins 8192 May 26 11:23 ..
drwxr-xr-x 6 jenkins jenkins 84 Apr 11 08:11 fonts
drwx------ 3 jenkins jenkins 88 Sep 24 2021 .userPrefs
.java/fonts:
total 16
drwxr-xr-x 6 jenkins jenkins 84 Apr 11 08:11 .
drwxr-xr-x 4 jenkins jenkins 47 Sep 24 2021 ..
drwxr-xr-x 2 jenkins jenkins 4096 Oct 22 2021 11.0.12
drwxr-xr-x 2 jenkins jenkins 4096 Feb 10 08:21 11.0.13
drwxr-xr-x 2 jenkins jenkins 4096 Mar 8 16:10 11.0.14
drwxr-xr-x 2 jenkins jenkins 4096 Apr 11 09:28 11.0.14.1
.java/fonts/11.0.12:
total 204
drwxr-xr-x 2 jenkins jenkins 4096 Oct 22 2021 .
drwxr-xr-x 6 jenkins jenkins 84 Apr 11 08:11 ..
-rw------- 1 jenkins jenkins 7299 Oct 22 2021 fcinfo-1-040d00baa2eb-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Sep 14 2021 fcinfo-1-20ca101e47b5-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 22 2021 fcinfo-1-21c8cfa68082-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 22 2021 fcinfo-1-37affa299e53-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 22 2021 fcinfo-1-5711e7474638-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 22 2021 fcinfo-1-6b1683e97998-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Sep 14 2021 fcinfo-1-728bf3c61133-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Sep 30 2021 fcinfo-1-7b86df010aaf-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Sep 28 2021 fcinfo-1-832b491f4c04-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 22 2021 fcinfo-1-86aba7d01298-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 22 2021 fcinfo-1-8932a30d6877-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Sep 14 2021 fcinfo-1-96bd7f94e38b-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Sep 14 2021 fcinfo-1-a1583396148a-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 22 2021 fcinfo-1-a1bb55b4d274-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 13 2021 fcinfo-1-a7f7f4177010-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 22 2021 fcinfo-1-b12b7fd6f0c7-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Sep 28 2021 fcinfo-1-b1b0d9227a50-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Sep 13 2021 fcinfo-1-b503c6b64359-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 1 2021 fcinfo-1-bc04fbd5ff6c-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 13 2021 fcinfo-1-dfeccf9ddb48-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Sep 28 2021 fcinfo-1-e3c99d9e381b-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 13 2021 fcinfo-1-e8da60a9a257-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 22 2021 fcinfo-1-eaebb37b5977-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Sep 14 2021 fcinfo-1-f32e3c0ebecd-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Oct 22 2021 fcinfo-1-f9d0aa853241-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
.java/fonts/11.0.13:
total 172
drwxr-xr-x 2 jenkins jenkins 4096 Feb 10 08:21 .
drwxr-xr-x 6 jenkins jenkins 84 Apr 11 08:11 ..
-rw------- 1 jenkins jenkins 7299 Nov 22 2021 fcinfo-1-097221e8a108-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Feb 10 07:58 fcinfo-1-41845738ebe1-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Jan 4 12:34 fcinfo-1-46e0ccd45a88-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Nov 12 2021 fcinfo-1-474a19c2cce4-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Dec 7 09:09 fcinfo-1-614acd73e811-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Jan 31 17:36 fcinfo-1-6962f56c161d-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Dec 30 10:55 fcinfo-1-85261a0f7ec2-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Nov 26 11:35 fcinfo-1-85956c8d5f07-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Jan 27 10:22 fcinfo-1-88d1b31b3765-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Dec 7 08:50 fcinfo-1-8f030abd9c75-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Nov 24 2021 fcinfo-1-99beaa989281-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Feb 10 07:23 fcinfo-1-ace5ac3b63e6-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Feb 1 09:40 fcinfo-1-b0b039be646a-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Jan 13 09:05 fcinfo-1-b2d98a3161f6-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Nov 12 2021 fcinfo-1-c22fc2f4765b-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Dec 7 09:00 fcinfo-1-d522e357e0ae-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Jan 13 08:57 fcinfo-1-d8918f1e34ac-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Nov 19 2021 fcinfo-1-dcb3e5ad8a04-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Feb 10 07:37 fcinfo-1-f553c95bca98-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Jan 13 09:13 fcinfo-1-f9e9b7738fab-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Feb 10 08:21 fcinfo-1-facf3dc3fd74-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
.java/fonts/11.0.14:
total 36
drwxr-xr-x 2 jenkins jenkins 4096 Mar 8 16:10 .
drwxr-xr-x 6 jenkins jenkins 84 Apr 11 08:11 ..
-rw------- 1 jenkins jenkins 7299 Mar 8 08:06 fcinfo-1-3d402af251bf-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Mar 8 08:19 fcinfo-1-4c7ea1c83a38-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Mar 8 16:10 fcinfo-1-ccb90ea5dcfc-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Mar 8 14:37 fcinfo-1-d59c3d909628-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
.java/fonts/11.0.14.1:
total 28
drwxr-xr-x 2 jenkins jenkins 4096 Apr 11 09:28 .
drwxr-xr-x 6 jenkins jenkins 84 Apr 11 08:11 ..
-rw------- 1 jenkins jenkins 7299 Apr 11 08:16 fcinfo-1-05e5f5147559-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Apr 11 08:11 fcinfo-1-7d587d1071d0-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
-rw------- 1 jenkins jenkins 7299 Apr 11 09:28 fcinfo-1-837bffc706fb-Linux-3.10.0-1160.6.1.el7.x86_64-en.properties
.java/.userPrefs:
total 0
drwx------ 3 jenkins jenkins 88 Sep 24 2021 .
drwxr-xr-x 4 jenkins jenkins 47 Sep 24 2021 ..
drwxr-xr-x 3 jenkins jenkins 49 Sep 24 2021 org
-rw------- 1 jenkins jenkins 0 Sep 24 2021 .user.lock.jenkins
-rw------- 1 jenkins jenkins 0 Sep 24 2021 .userRootModFile.jenkins
.java/.userPrefs/org:
total 4
drwxr-xr-x 3 jenkins jenkins 49 Sep 24 2021 .
drwx------ 3 jenkins jenkins 88 Sep 24 2021 ..
drwxr-xr-x 3 jenkins jenkins 47 Sep 24 2021 codehaus
-rw-r--r-- 1 jenkins jenkins 148 Sep 24 2021 prefs.xml
.java/.userPrefs/org/codehaus:
total 4
drwxr-xr-x 3 jenkins jenkins 47 Sep 24 2021 .
drwxr-xr-x 3 jenkins jenkins 49 Sep 24 2021 ..
drwxr-xr-x 3 jenkins jenkins 46 Sep 24 2021 groovy
-rw-r--r-- 1 jenkins jenkins 148 Sep 24 2021 prefs.xml
.java/.userPrefs/org/codehaus/groovy:
total 4
drwxr-xr-x 3 jenkins jenkins 46 Sep 24 2021 .
drwxr-xr-x 3 jenkins jenkins 47 Sep 24 2021 ..
-rw-r--r-- 1 jenkins jenkins 148 Sep 24 2021 prefs.xml
drwxr-xr-x 3 jenkins jenkins 46 Sep 24 2021 tools
.java/.userPrefs/org/codehaus/groovy/tools:
total 4
drwxr-xr-x 3 jenkins jenkins 46 Sep 24 2021 .
drwxr-xr-x 3 jenkins jenkins 46 Sep 24 2021 ..
-rw-r--r-- 1 jenkins jenkins 148 Sep 24 2021 prefs.xml
drwxr-xr-x 2 jenkins jenkins 30 Sep 24 2021 shell
.java/.userPrefs/org/codehaus/groovy/tools/shell:
total 4
drwxr-xr-x 2 jenkins jenkins 30 Sep 24 2021 .
drwxr-xr-x 3 jenkins jenkins 46 Sep 24 2021 ..
-rw-r--r-- 1 jenkins jenkins 148 Sep 24 2021 prefs.xml
I am building a a "custom" jenkins agent (based on the public jenkins/agent:jdk8 image) docker image using the below dockerfile:
FROM jenkins/agent:jdk8
USER root
RUN apt-get -qq update \
&& apt-get -qq -y install \
curl
RUN curl -sSL https://get.docker.com/ | sh
RUN date > /home/jenkins/build-date-root.txt
USER jenkins
RUN date > build-date.txt
I build with:
docker build -t internal/jenkins-custom-agent docker
When I run the image on my local machine with
docker run -it --rm internal/jenkins-custom-agent bash
I can see the 2 added files as expected inside the container:
jenkins#local:~$ pwd
/home/jenkins
jenkins#local:~$ ls -la
total 48
drwxr-xr-x 1 jenkins jenkins 4096 Feb 20 11:35 .
drwxr-xr-x 1 root root 4096 Feb 15 20:28 ..
-rw-r--r-- 1 jenkins jenkins 220 Apr 18 2019 .bash_logout
-rw-r--r-- 1 jenkins jenkins 3526 Apr 18 2019 .bashrc
drwxr-xr-x 2 jenkins jenkins 4096 Feb 20 09:38 .gradle
drwxr-xr-x 2 jenkins jenkins 4096 Feb 15 20:28 .jenkins
-rw-r--r-- 1 jenkins jenkins 807 Apr 18 2019 .profile
drwxr-xr-x 2 jenkins jenkins 4096 Feb 15 20:28 agent
-rw-r--r-- 1 root root 29 Feb 20 09:38 build-date-root.txt
-rw-r--r-- 1 jenkins jenkins 29 Feb 20 09:38 build-date.txt
But when I run a container from the exact same image (pushed to our internal registry) in jenkins running in Kubernetes those files are not there:
11:18:30 + ls -la /home/jenkins
11:18:30 total 40
11:18:30 drwxrwxrwx 10 root root 4096 Feb 20 10:18 .
11:18:30 drwxr-xr-x 1 root root 4096 Feb 15 20:28 ..
11:18:30 drwxr-xr-x 3 jenkins jenkins 4096 Feb 20 10:18 .cache
11:18:30 drwxr-xr-x 3 jenkins jenkins 4096 Feb 20 10:18 .config
11:18:30 drwxr-xr-x 2 jenkins jenkins 4096 Feb 15 20:28 .jenkins
11:18:30 drwx------ 2 jenkins jenkins 4096 Feb 20 10:18 .ssh
11:18:30 drwxr-xr-x 2 jenkins jenkins 4096 Feb 15 20:28 agent
11:18:30 drwxr-xr-x 3 jenkins jenkins 4096 Feb 20 10:18 caches
11:18:30 drwxr-xr-x 4 jenkins jenkins 4096 Feb 20 10:18 remoting
11:18:30 drwxr-xr-x 3 jenkins jenkins 4096 Feb 20 10:18 workspace
I suspect it has something to do with how its started in kubernetes/jenkins and the cat command:
But I don't understand how that can prevent files that I know is in the image to suddenly disappear.
Is it not possible to "extend" jenkins/agent:jdk8 and add my own custom files/folders etc?
UPDATE:
I found this:
https://support.cloudbees.com/hc/en-us/articles/360031223512-What-you-need-to-know-when-using-Kaniko-from-Kubernetes-Jenkins-Agents?mobile_site=true&page=7
And based on that I have now changed to using
workingDir: /tmp/jenkins
for the two containers and now I can find the files in the image:
16:23:50 + ls -la /home/jenkins
16:23:50 total 40
16:23:50 drwxr-xr-x 1 jenkins jenkins 4096 Feb 20 09:38 .
16:23:50 drwxr-xr-x 1 root root 4096 Feb 15 20:28 ..
16:23:50 -rw-r--r-- 1 jenkins jenkins 220 Apr 18 2019 .bash_logout
16:23:50 -rw-r--r-- 1 jenkins jenkins 3526 Apr 18 2019 .bashrc
16:23:50 drwxr-xr-x 2 jenkins jenkins 4096 Feb 20 09:38 .gradle
16:23:50 drwxr-xr-x 2 jenkins jenkins 4096 Feb 15 20:28 .jenkins
16:23:50 -rw-r--r-- 1 jenkins jenkins 807 Apr 18 2019 .profile
16:23:50 drwxr-xr-x 2 jenkins jenkins 4096 Feb 15 20:28 agent
16:23:50 -rw-r--r-- 1 root root 29 Feb 20 09:38 build-date-root.txt
16:23:50 -rw-r--r-- 1 jenkins jenkins 29 Feb 20 09:38 build-date.txt
The do "explain" that in the article but it to low-level for me to understand.
I have a recent version of GVM - in fact, my entire machine is very recent as I wiped off Windows and installed Linux Mint 17 at the end of May or beginning of June. GVM does not install software, doesn't even create the directory (in the example, no 2.4.2 directory - as you can see, the mv fails for this reason). I have had to install the products manually. The "current" points to a non-existent instance if I fail to do so. This has been true of Grails, Groovy and Gradle.
Here is an example:
worldwidewilly#hal9000 ~ $ gvm install grails 2.4.2
Downloading: grails 2.4.2
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:05 --:--:-- 0
100 131M 100 131M 0 0 1208k 0 0:01:51 0:01:51 --:--:-- 2092k
Installing: grails 2.4.2
mv: target ‘/home/worldwidewilly/.gvm/grails/2.4.2’ is not a directory
Done installing!
Do you want grails 2.4.2 to be set as default? (Y/n): y
Setting grails 2.4.2 as default.
What need I do to not fail on the install? Are there dependencies in Linux that I need install?
EDIT #1 - adding requested ls
worldwidewilly#hal9000 ~ $ \ls -la ~/.gvm
total 64
drwxr-xr-x 16 worldwidewilly worldwidewilly 4096 Jun 15 12:27 .
drwxr-xr-x 53 worldwidewilly worldwidewilly 4096 Jul 9 22:11 ..
drwxr-xr-x 2 worldwidewilly worldwidewilly 4096 Jul 9 07:58 archives
drwxr-xr-x 2 worldwidewilly worldwidewilly 4096 Jun 15 12:26 bin
drwxr-xr-x 2 worldwidewilly worldwidewilly 4096 Jun 15 12:26 crash
drwxr-xr-x 2 worldwidewilly worldwidewilly 4096 Jun 15 12:26 etc
drwxr-xr-x 2 worldwidewilly worldwidewilly 4096 Jun 15 12:26 ext
drwxr-xr-x 2 worldwidewilly worldwidewilly 4096 Jun 15 12:26 gaiden
drwxr-xr-x 2 worldwidewilly worldwidewilly 4096 Jun 15 12:26 glide
drwxr-xr-x 3 worldwidewilly worldwidewilly 4096 Jun 28 20:54 gradle
drwxr-xr-x 3 worldwidewilly worldwidewilly 4096 Jul 9 08:11 grails
drwxr-xr-x 2 worldwidewilly worldwidewilly 4096 Jun 15 12:26 griffon
drwxr-xr-x 3 worldwidewilly worldwidewilly 4096 Jun 15 12:27 groovy
drwxr-xr-x 2 worldwidewilly worldwidewilly 4096 Jun 15 12:26 src
drwxr-xr-x 6 worldwidewilly worldwidewilly 4096 Jul 9 08:00 tmp
drwxr-xr-x 2 worldwidewilly worldwidewilly 4096 Jun 15 12:27 var
EDIT #2 - adding second second ls
worldwidewilly#hal9000 ~ $ ls -la ~/.gvm/grails
total 12K
524305 drwxr-xr-x 3 worldwidewilly worldwidewilly 4.0K Jul 9 08:11 .
59776162 drwxr-xr-x 16 worldwidewilly worldwidewilly 4.0K Jun 15 12:27 ..
19138378 drwxr-xr-x 10 worldwidewilly worldwidewilly 4.0K Jun 17 10:09 2.4.1
524458 lrwxrwxrwx 1 worldwidewilly worldwidewilly 38 Jul 9 08:11 current -> /home/worldwidewilly/.gvm/grails/2.4.2
EDIT #3 - showing contents of 2.4.1 directory
worldwidewilly#hal9000 ~ $ ls -la ~/.gvm/grails/2.4.1
total 284K
19138378 drwxr-xr-x 10 worldwidewilly worldwidewilly 4.0K Jun 17 10:09 .
524305 drwxr-xr-x 3 worldwidewilly worldwidewilly 4.0K Jul 9 08:11 ..
19267975 drwxr-xr-x 2 worldwidewilly worldwidewilly 4.0K Jun 17 10:10 bin
19138379 -rw-r--r-- 1 worldwidewilly worldwidewilly 22 Jun 17 09:30 build.properties
19267980 drwxr-xr-x 2 worldwidewilly worldwidewilly 4.0K Jun 17 10:10 conf
19267984 drwxr-xr-x 2 worldwidewilly worldwidewilly 64K Jun 17 10:10 dist
19138380 -rw-r--r-- 1 worldwidewilly worldwidewilly 117 Jun 17 09:20 INSTALL
19138382 drwxr-xr-x 62 worldwidewilly worldwidewilly 4.0K Jun 17 10:09 lib
19138381 -rw-r--r-- 1 worldwidewilly worldwidewilly 171K Jun 17 09:20 LICENSE
19267653 drwxr-xr-x 4 worldwidewilly worldwidewilly 4.0K Jun 17 09:20 media
19267952 drwxr-xr-x 2 worldwidewilly worldwidewilly 4.0K Jun 17 10:10 plugins
19138931 -rw-r--r-- 1 worldwidewilly worldwidewilly 2.5K Jun 17 09:20 README
19267876 drwxr-xr-x 2 worldwidewilly worldwidewilly 4.0K Jun 17 10:10 scripts
19267676 drwxr-xr-x 5 worldwidewilly worldwidewilly 4.0K Jun 17 10:09 src
EDIT #4 - adding zip info
worldwidewilly#hal9000 ~ $ which zip
/usr/bin/zip
worldwidewilly#hal9000 ~ $ zip -h
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
The default action is to add or replace zipfile entries from list, which
can include the special name - to compress standard input.
If zipfile and list are omitted, zip compresses stdin to stdout.
-f freshen: only changed files -u update: only changed or new files
-d delete entries in zipfile -m move into zipfile (delete OS files)
-r recurse into directories -j junk (don't record) directory names
-0 store only -l convert LF to CR LF (-ll CR LF to LF)
-1 compress faster -9 compress better
-q quiet operation -v verbose operation/print version info
-c add one-line comments -z add zipfile comment
-# read names from stdin -o make zipfile as old as latest entry
-x exclude the following names -i include only the following names
-F fix zipfile (-FF try harder) -D do not add directory entries
-A adjust self-extracting exe -J junk zipfile prefix (unzipsfx)
-T test zipfile integrity -X eXclude eXtra file attributes
-y store symbolic links as the link instead of the referenced file
-e encrypt -n don't compress these suffixes
-h2 show more help
The problem was that I had improperly aliased my mv command, which caused mv to break. See http://forums.linuxmint.com/viewtopic.php?f=90&t=174548 for a deeper explanation.