I am building a system to do c++ cmake builds primarily. I have Jenkins firing the dynamic pods, firing off shell scripts, etc. But, I can't get it to checkout the code. Now, my Jenkinsfile launches a container that the actual compile is supposed to be run in. That "sub" container is tuned to compile C++ code. Now, I have jenkins running scripts and such in that pod, but, when i try
checkout scm
im getting errors saying
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --force --progress git#gitlab.com:mystuff/hello-world-cmake.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: No user exists for uid 1000080000
fatal: Could not read from remote repository.
my home folder is the standard /home/jenkins and the workspace folder is there, etc, etc. But, when I dump the /etc/passwd file, the jenkins user isn't listed in it.
Whats the appropriate way to add the jenkins user to that file?
What image are you using for Jenkins slave? Does it have user jenkins? If it has you need to specify this in your spec for Jenkins slave:
spec:
securityContext:
runAsUser: 1000
UPDATE:
You cannot run default Jenkins image in Openshift, because Openshift runs containers as random user. You should run Jenkins from builtin Jenkins template "Jenkins Persistent". If you don't have this template and don't have Jenkins image stream - you can try to use image openshift/jenkins-2-centos7. See details at:
https://github.com/openshift/jenkins/issues/168
https://github.com/openshift/jenkins
Related
step1:I deploymented jenkins、rancher、gitlab servers in my local environment.I would want to realize CI/CD pipeline.
step2:My project is a web-based management system which used vue and gin.The project source code was pushed into the gitlab repository.I wrote a Dockerfile and a Jenkinsfile in my local IDE.The next is my important description.In my Jenkinsfile:there is some statement like the following shows :
steps {
sh "kubectl set image deployment/gin-vue gin-vue=myhost/containers/gin-vue.${BUILD_NUMBER} -n web"
}
Then executed git commit and git push command.
step3:I created a task in jenkins and clicked the build button to run the corresponding pipeline script.
step4:After end running,the newer image could not be updated into the rancher.
enter image description here
But I executed this command in rancher kubectl client terminal "kubectl set image deployment/gin-vue gin-vue=myhost/containers/gin-vue.${BUILD_NUMBER} -n web" could be successful.
So what's the cause of this problem?And this confused me so many days and not found the solution.Thanks a lot!
I executed this command in rancher kubectl client terminal "kubectl set image deployment/gin-vue gin-vue=myhost/containers/gin-vue.${BUILD_NUMBER} -n web" could be successful.
I configure Jenkins Pipeline. Provide GitHub Project->Project url and configure Pipeline to use Pipeline script from SCM, Set Script path to folder/Jenkinsfile and check Lightweight checkout.
Everything is fine, but when I start second build in parallel I get error:
Below I can see these:
hudson.plugins.git.GitException: Command "/usr/bin/git checkout -f 037bf3d91be78647a7bb2977623b32cf2749c8e2" returned status code 128:
stdout:
stderr: error: unable to create file services/mysql/conf.d/default_auth.cnf: Permission denied
fatal: cannot rmdir 'services/mysql/seed_additional_databases.sh': Permission denied
I have checked those files are owned by Jenkins, but probably busy by first build.
Why for second build Jenkins do checkout into folder for first build?
I'm trying to set up jenkins to run some pipelines for me. As part of my pipeline, I want to checkout a second git repository, which I am placing into a subdirectory of the workspace.
However, this pipeline step will fail on a clean workspace, with an error like:
! [new branch] develop -> origin/develop (unable to update local ref)
error: cannot lock ref 'refs/remotes/origin/master': unable to resolve reference 'refs/remotes/origin/master': Not a directory
From what I can tell, this is happening because git is failing to create the .git/refs/remotes/origin/master file (however it does manage to create the .git/refs/remotes/origin/ directory, which isn't created by the git init command).
Upon playing around, I can reproduce this issue in the docker container by creating a new empty directory and running
git init
git fetch --tags --force --progress -- {giturl} +refs/heads/*:refs/remotes/origin/*
which appears to be what the jenkins step is doing.
If I run the git fetch a second time, it will then succeed.
So far, this is all within a mounted volume in the container. If I try to recreate the problem not in a mounted container, I can't. The
git init
git fetch --tags --force --progress -- {giturl} +refs/heads/*:refs/remotes/origin/*
steps work as expected, meaning that something appears to be going wrong within the mounted volume for some reason.
Does anyone know what might causing these issues within the mounted volume?
Incidentally I also have a stage doing:
bat "\"C:/Program Files/LLVM/bin/clang-format.exe\" -n --style=file --fallback-style=none .\\Source\\*.c .\\Source\\*.cpp .\\Source\\*.h .\\Source\\*.hpp 2>&1 | python ./libraries/clang-to-junit.py ${WORKSPACE} Clang-Format > clang-format-results.xml"
bat "type clang-format-results.xml"
junit allowEmptyResults: true, skipOldReports: true, skipPublishingChecks: true, testResults: 'clang-format-results.xml'
which creates a clang-format-results.xml file to report results of clang format. However the junit step fails to find the file if it's newly created, despite the type command outputting the file just fine. Seems like this could be related also to filesystem issues...
I have this command at the top of my pipeline file, and my build failed immediately in Jenkins while trying to resolve it:
#Library('MyLibrary') _
pipeline{
...
I also have this library setup in my global jenkins config. Triple checked it.
The Jenkins log is below... the internet says this happens when git.exe is misconfigured or not found. We have 100% verified git is installed on all the slaves. However, I suspect that this failing git clone is running somewhere else since the pipeline has not officially started yet (we don't see RUNNING ON: blah in the log).
So... Does it run this on the master? We have master set to 0 executors, and git is not installed there.
Is this problem solved as easily as installing git on the master? Or is there some other magical place where these #Library includes get cloned?
Here is the Jenkins log output, with names changed to protect the innocent:
Started by user Me
15:28:23 Connecting to my github url
Obtained Jenkinsfile from blah
Running in Durability level: MAX_SURVIVABILITY
Loading library MyLibrary#master
Examining <my github repo>
Attempting to resolve master as a branch
Resolved master as branch master at revision blah
No credentials specified
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository <my repo url>.git
> git init /home/afolder/jenkins/workspace/<git repo name>#libs/MyLibrary # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init /home/afolder/jenkins/workspace/<git repo name>#libs/MyLibrary
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:813)
...
Caused by: java.io.IOException: Cannot run program "git" (in directory
"/home/afolder/jenkins/workspace/<git repo name>#libs/MyLibrary"):
error=2, No such file or directory
Yes, by default it will run on the Jenkins master.
Please follow the link for more info.
You can read library file and give the file to writeFile pipeline step
writeFile(file:"foo.groovy", text: libraryResource("bar.groovy"))
"groovy foo.groovy"
I want to checkout a git repo and then run its build so I tried:
sh "git clone --depth 1 -b master git#github.com:user/repo.git"
build './repo'
but that yields:
ERROR: No item named ./repo found
I've tried to use dir('repo') but apparently that errors when you run it from within docker (because kubernetes is stuck on an old version of docker that doesnt support this).
Any idea on how to run the build pipeline from the checked out repo?
The 'build' pipeline steps expect a job name, not a pipeline folder with a Jenkinsfile in its root folder.
The correct way to do this is to set the pipeline job with the Jenkinsfile, as described here ('In SCM' section), and call it by its Job name from your pipeline.
Pipelines are not built for chaining unless you use shared libraries where you put the Pipeline code in a Groovy class or as a step, but that it is a subject for a full article.