Cache folder not writable Bitbucket Docker - docker

I have currently a problem to build and to run my app using bitbucket pipeline:
I have a error about the cache folder which is not writable:
warning Skipping preferred cache folder "/home/node/.cache/yarn" because it is not writable.
warning Skipping preferred cache folder "/tmp/.yarn-cache-1000" because it is not writable.
warning Skipping preferred cache folder "/tmp/.yarn-cache" because it is not writable.
error Yarn hasn't been able to find a cache folder it can use. Please use the explicit --
cache-folder option to tell it what location to use, or make one of the preferred locations
writable.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I'm using a bitbucket-pipelines.yml and a dockerfile.
Thank you

I came across the same problem (also using Docker and Bitbucket Pipelines). Except that I was using k8s to deploy the app.
What I did was change the next line in my deployment to false:
securityContext:
readOnlyRootFilesystem: false (it was `true`)
It solved it for me!

Related

Change /tmp folder for jenkins in debian

I recently had a low disc space issue in jenkins. Although the home directory has sufficient space, the /tmp did not and it brought my master down.
I tried many ways to fix this
Discard old build and deleting old workspaces
Restarting jenkins
Tried to setup a node with same config and starting it, but that failed saying i dont have sufficient permission for copying remote.jar
Since my server is debian, I could not find any file where I could set set -Djava.io.tmpdir
Many people talked about jenkin file or config file, but I could not find it.
The only thing that worked was https://updates.jenkins-ci.org/download/plugins/tmpcleaner/ , this plugin hpi, which I installed through Advanced tag in plugins.
Also, I went manually to the /tmp folder in root and then deleted it contents to start the jenkins again. So my question is:
How do i change the /tmp folder in jenkins?
The jenkins home directory is /mnt/data/jenkins, however the tmp it uses it root/tmp. Why is it so? The /mnt/data/jenkins has lots of free space and i manually created a /tmp folder there, but it only takes the /tmp from the root
My colleague found the answer out
open '/etc/defaults/jenkins' file using command 'less /etc/defaults/jenkins'
Add argument
JAVA_ARGS="$JAVA_ARGS -Djava.io.tmpdir=yourNewtempLocation"
Once you restart jenkins, you will be able to see the storage of the new space

Changing JENKINS_HOME to another hard disk

I tried many tutorials I found on the internet on how to change the location of my JENKINS_HOME.
I still encountered these errors:
On the jenkins app - Unable to create the home directory ‘/mnt/2fe95e40-f8ba-418e-804c-0a25571f7b0c/jenkins’. This is most likely a permission problem.
On the jenkins logs - SEVERE hudson.util.BootFailure#publish: Failed to initialize Jenkins
hudson.util.NoHomeDir
In the the tutorials they are saying that one of the reasons to change the JENKINS_HOME is the issue of the disk space, but their steps were always to change the directory to a new /home/<new_folder>. They are still using the same drive, they just change the folder it does not fix their disk space problem.
Does anyone know how to use the another hard disk as the new JENKINS_HOME? Without having to use
SymLink or Symbolic Link that point to another drive.
I am using Ubuntu 18.04.1 x64
Thanks.
I would do a fresh install on the new hard disk, then make a backup from the old location and restore it on the new disk.
If you do not agree with this approach you should check which user has permission on the Jenkins files and folders on the new hard disk.
stat [yourfilename or yourfolder]
Compare with JENKINS_USER variable in etc/default/jenkins.
Change the user if needed on the new location:
chown -R your_user /var/lib/jenkins
You will need to restart Jenkins and maybe reboot the machine.
As a second option, maybe Jenkins can not create its home directory in the new place. You can create the directory manually and then change JENKINS_HOME to point to it.
More info:
https://wiki.jenkins.io/display/JENKINS/Administering+Jenkins
https://askubuntu.com/questions/175054/how-to-find-owner-and-group-of-a-directory
Run jenkins job as another user
Can't get Jenkins to start using Tomcat

Same VSCode-Settings for the whole crew?

We want to have the same VSCode settings for the whole crew of developers. Also it would be fine to have a oneline command to tear VSCode down and restart it from scratch with predefined settings and plugins so that you do not have to worry about trying out plugins and getting beck to the known state. Kind of Config-as-Code for VSCode.
I already found:
https://code.visualstudio.com/docs/editor/extension-gallery#_command-line-extension-management
https://github.com/microsoft/vscode-dev-containers
https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync&ssr=false#qna
https://github.com/gantsign/ansible-role-visual-studio-code-extensions
https://code.visualstudio.com/docs/remote/containers
https://github.com/gantsign/ansible-role-visual-studio-code
But non of these provides a good solution to me
We are using Mac and Windows machines and develop most of the time locally (not remotely in the cloud or the like).
I imagine like having a script like
.... projectname up
or
.... projectname reset
(or
.... projectname down)
to receive/reset the configured settings and newest plugins that have been configured for the project.
Have any ideas or use a similar solution already?
After doing a lot of research, playing with Docker, Ansible and so on... it seems that although I excluded it at first the plugin Settings Sync Plugin from Shan Khan is the way to go. It has round about 1 million installs!
Only dependency - you need a GitHub account to host your configs. That is what held me back at first - but it should be not that much of a problem to get one for everyone in the team and connect it to like a company-github-account.
Copy the files settings.json and keybindings.json to your target machine(s) to copy the settings. You can find those files here:
Win: ~\AppData\Roaming\Code\User
Mac: ~/Library/Application Support/Code/User/
Linux: ~/.config/Code/User
You can copy extentions from ~/.vscode/extensions or C:\Users\username\.vscode\extensions from linux/mac or windows respectively.
FalcoGer's answer should explain how to copy the files in a way VS Code will pick them up. If you only need to copy the config files once, this solution would be fine.
If you need to "sync" these config files on a regular basis, I would advise to create a Git repository where all config files will be stored.
When cloning the repo to local machines, you can symlink the files to the config destinations (see FalcoGer's anwser). Then when you need to "sync", you only have to run git pull and restart VS Code to apply the changes.
For your other script-related question, you could create a CLI for this. Python would be the most friendly way to do this. You can find an example here.

ADD command with network path in Windows Containers Dockerfiles

I'm creating some Windows Container images that I need but the source file I want to ADD are in a network share \\myserver\myshare\here.
I've tried in any possible way but I always get the message error The system cannot find the path specified.
Is it because I have not yet found the right way to set it or is it that it is just not possible?
From the Docker site:
Multiple resource may be specified but if they are files or directories then they must be relative to the source directory that is being built (the context of the build).
Is that why I can't accomplish what I need?
Full error message: GetFileAttributesEx \\myserver\myshare\here\: The system cannot find the path specified.
Whatever you ADD or COPY must be in the docker build context.
When you do this:
docker build .
That directory param (the . in the example) is the context that is copied and sent to the Docker daemon. Then the docker daemon use those files to COPY or ADD. It won't use any file that is not in that context.
That is the issue that you are experiencing. I'm not sure how you can solve it anything than copying the files from \\myserver to your build directory.
ADD is capable of download files by providing an URL (should investigate if it supports Windows' shares)

SVN poll failed in custom workspace, reporting "Workspace appear to be locked"

Building in workspace /data/www/wdqk/html/flash
Updating svn://192.168.1.200/wdqk/www/html/flash at revision '2013-09-17T15:15:15.460 +0800'
Workspace appear to be locked, so getting a fresh workspace
Cleaning local Directory .
java.io.IOException: Unable to delete /data/www/wdqk/html/flash/./.svn/entries
at hudson.Util.deleteFile(Util.java:255)
at hudson.Util.deleteRecursive(Util.java:307)
at hudson.Util.deleteContentsRecursive(Util.java:204)
at hudson.Util.deleteRecursive(Util.java:298)
at hudson.Util.deleteContentsRecursive(Util.java:204)
at hudson.scm.subversion.CheckoutUpdater$1.perform(CheckoutUpdater.java:75)
at hudson.scm.subversion.WorkspaceUpdater$UpdateTask.delegateTo(WorkspaceUpdater.java:153)
at hudson.scm.subversion.WorkspaceUpdater$UpdateTask.delegateTo(WorkspaceUpdater.java:161)
at hudson.scm.subversion.UpdateUpdater$TaskImpl.perform(UpdateUpdater.java:182)
at hudson.scm.subversion.WorkspaceUpdater$UpdateTask.delegateTo(WorkspaceUpdater.java:153)
at hudson.scm.SubversionSCM$CheckOutTask.perform(SubversionSCM.java:903)
at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:884)
at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:867)
at hudson.FilePath.act(FilePath.java:909)
at hudson.FilePath.act(FilePath.java:882)
at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:843)
at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:781)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1408)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
at hudson.model.Run.execute(Run.java:1603)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:247)
Finished: FAILURE
This build is outside Jenkins's home directory.
I cannot find any lock file in the svn project folder.
Is it the permission issue?
Yes, it's most likely a permission issue. As I see it, you have few ways to resolve it.
Make your jenkins user the owner of the project folders. You already said in the comments that you don't want to do that.
Set chmod a+w on your project folders. I would not recommend this as everybody would have write access to the folders. Could become as security issue.
Create a new group, say groupadd development. Add your jenkins user and the owner of the project folders to that group (usermod -a -G development jenkins and usermod -a -G development owneruser). Now change the owner group of the project folders (chown :development projectfolder). Make sure the group has write access (chmod g+w) This one is a little bit of work but I think it's the best way.
The "Workspace appear to be locked" is not the actual error by the way. It's just an information telling you that (and why) the workspace is cleaned and checked out again. The actual error happens while cleaning the workspace but not because it's locked.

Resources