I have a simple c++ to compile and run using jenkins freestyle job it is working fine if I use jenkins built in my OS (Linux mint tricia) commands I use:
cd "destination"
g++ main.cpp -o test
./test
everything is working good.
BUT,now I m running jenkins from docker container and when I try to do this I get error cant cd to "destination", I know this is because docker is isolated from host machine, So I want to ask how could I make a simple freestyle job which executes programs which is on my host machine using jenkins which is running inside docker?
Thank You
Just run your jenknis container with volume like docker run -it -v destination:destination jenkins
Related
I'm a beginner in docker, as well as in team city, I set up a pipeline for a build of a docker container and wanted to configure it to run after a successful build, I tried to use a step with a docker, but they advise using the command line with executable parameter and some way with docker socket, I crossed the Internet / YouTube did not see normal examples for starting a container after a build. I saw some examples of launching with agents, but again I did not understand anything in what was written, I looked for examples on YouTube, I also did not find it. Please give an example of running docker as a step in the pipeline on Linux.
I solved my similar requirement on Jenkins by applying following..
Add a shell file (e.g. run.sh) in your project. In there have the docker run command that you will use from command line adding > /dev/null 2>&1 & at the end so that the process can be run in background and O/P streams to null.
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag > /dev/null 2>&1 &
Then in your Jenkins (Teamcity) script add a sh step to run this file
steps {
dir (whatever-dir-run.sh-is-in) {
sh "JENKINS_NODE_COOKIE=dontKillMe sh run.sh"
}
}
Note: If JENKINS_NODE_COOKIE has an equivalent in Teamcity, use that.
I need some help with docker configuration on TFS. I've got some experience but not much. I have configured classic CI for .NET projects few times where these steps were used:
-get sources
-run tests
-build
-copy files to server
Recently I've started to use Docker and I would like to automate this process, because now I have to copy files manually to remote machine and then run these commands:
dotnet publish --configuration=Release -o pub
docker build . -t netcore-rest
docker run -e Version=1.1 -p 9000:80 netcore-rest
I saw few tutorials for VSTS, but I'd like to configure it for classic TFS.
I don't have docker hub. What interesting me is:
-how to kill/remove currently running container
-build new one from copied files
-run a new container
Thank you
PS. I have already installed docker on my agent machine, so it's able to build an image.
Trying to do config transformation once a docker container has been created and the docker CP command does not allow wildcard and file type searches. While testing manually, it was found that it was possible to solve this issue but running the docker exec command and running powershell inside our container. After some preliminary tests it doesn't look like this works out of the box with octopus deploy. Is there a way to run process steps inside a container with octopus deploy?
Turns out you can run powershell scripts that already exist in the container with the exec command:
docker exec <container> powershell script.ps1 -argument foo
This command will run a script as you would expect in command line.
I'm working with a Jenkins install I've inherited. This install has the CloudBees Docker Custom Build Environment Plugin installed. We think this plugin gives us a nifty Build inside a Docker container checkbox in our build configuration. When we configure jobs with this option, it looks like (based on Jenkins console output) Jenkins runs the build with the following command
Docker container 548ab230991a452af639deed5eccb304026105804b38194d98250583bd7bb83q started to host the build
[WIP-Tests] $ docker exec -t 548ab230991a452af639deed5eccb304026105804b38194d98250583bd7bb83q /bin/sh -xe /tmp/hudson7939624860798651072.sh
However -- we've found that this runs /bin/sh with a very limited set of environmental variables -- including a $PATH that doesn't include /bin! So
How does the CloudBees Docker Custom Build Environment Plugin setup its /bin/sh environment. Is this user configurable via the UI (if so, where?)
It looks like Jenkins is using docker exec -- which i think means that it must have (invisibly) setup a container with a long running process using docker run. Doesn't anyone know how the CloudBees Docker Custom Build Environment Plugin plugin invokes docker run, and if this is user manageable?
Considering this plugin is "up for adoption", I would recommend the official JENKINS/Docker Pipeline Plugin.
It source code show very few recent commits.
But don't forget any container has a default entrypoint set to /bin/sh
ENTRYPOINT ["/bin/sh", "-c"]
Then:
The docker container is ran after SCM has been checked-out into a slave workspace, then all later build commands are executed within the container thanks to docker exec introduced in Docker 1.3
That means the image you will be pulling or building/running must have a shell, to allow the docker exec to execute a command in it.
I am running Jenkins job on a windows10 machine. And I have installed ubuntu shell on the windows. The Jenkins job works fine with windows batch commands. But it stuck there when I try to run bash command. For example, I created an Execute Windows batch command build step, if I put command bash -c ls, this command never finishes.
It works fine if I run the same command in the windows directly.
How can I configure Jenkins job to work with bash command?
Below is the build step configuration. There are two commands. The first one is used to install dependencies on my nodejs application. The second command is used to run a command in bash shell. The problem is that the build is stuck on the second command.
Have you made any Global configurations in jenkins. try giving the command with the home path of Ubuntu shell and re run the command once.