I'm trying to improve my build times for my Jenkins jobs and am trying to build docker containers with my dependencies preinstalled.
I have the following (partial) Jenkinsfile:
pipeline {
agent {
docker {
image 'docker-local.artifactory.com/app-chromium:latest'
registryUrl 'https://docker-local.artifactory.com/'
registryCredentialsId 'artifactoryapikey'
}
}
}
And, according to the logs, jenkins is properly downloading this image. The problem occurs when it tries to run it:
[Pipeline] withDockerContainer
swarm-sjc01-0270eda05830-0.0.0.0 seems to be running inside container 0270eda05830a074668a5864c52d153377eb67b6406e3912b99f79686cfaca1c
but /home/jenkins/workspace/app_PR-6011-N3O6YOXQAC4KEFHSOKKCS7CFV3GUTIIJAVHDJCR5T7LMXUPU3SLQ could not be found among []
but /home/jenkins/workspace/app_PR-6011-N3O6YOXQAC4KEFHSOKKCS7CFV3GUTIIJAVHDJCR5T7LMXUPU3SLQ#tmp could not be found among []
$ docker run -t -d -u 1000:1000 -w /home/jenkins/workspace/app_PR-6011-N3O6YOXQAC4KEFHSOKKCS7CFV3GUTIIJAVHDJCR5T7LMXUPU3SLQ -v /home/jenkins/workspace/app_PR-6011-N3O6YOXQAC4KEFHSOKKCS7CFV3GUTIIJAVHDJCR5T7LMXUPU3SLQ:/home/jenkins/workspace/app_PR-6011-N3O6YOXQAC4KEFHSOKKCS7CFV3GUTIIJAVHDJCR5T7LMXUPU3SLQ:rw -v /home/jenkins/workspace/app_PR-6011-N3O6YOXQAC4KEFHSOKKCS7CFV3GUTIIJAVHDJCR5T7LMXUPU3SLQ#tmp:/home/jenkins/workspace/app_PR-6011-N3O6YOXQAC4KEFHSOKKCS7CFV3GUTIIJAVHDJCR5T7LMXUPU3SLQ#tmp:rw -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** --entrypoint cat icm-docker-local.artifactory.swg-devops.com/app-chromium:latest
ERROR: Timeout after 10 seconds
[Pipeline] // withDockerContainer
Does anyone understand why it times out? If i provide a dockerfile instead (agent { dockerfile: true }) it builds fine. Not that this is not using the script like pipeline syntax but the newer declarative format.
Related
I'm new in Jenkins and learning it right now.
I read that modern way to use Jenkins is to use docker containers as agents so:
I created jenkins image with docker installed
FROM jenkins/jenkins:lts
USER root
RUN apt-get update -qq && \
apt-get install -qqy apt-transport-https ca-certificates curl gnupg2 software-properties-common && \
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - && \
apt-key fingerprint 0EBFCD88 && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \
apt-get update -qq && \
apt-get install -qqy docker-ce && \
usermod -aG docker jenkins && \
chown -R jenkins:jenkins $JENKINS_HOME/
USER jenkins
Created docker-compose (instend running docker run command all the time)
version: '3.8'
services:
jenkins:
image: tmateusz/jenkins:lts
privileged: true
user: root
ports:
- 8080:8080
- 50000:50000
container_name: jenkins
volumes:
- /MY_PATH/jenkins_configuration:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
networks:
- jenkins
networks:
jenkins:
name: jenkins_network
Installed Docker Pipeline plugin in Jenkins Controller
Created really simple pipeline to check it works:
pipeline {
agent {
docker {
image 'eclipse-temurin:11'
}
}
stages {
stage('Check versions') {
steps {
sh 'java --version'
}
}
}
}
And it fails.
Checked again:
When I exec jenkins container (docker exec -it jenkins bash) - "docker ps" works (so docker is installed in Jenkins controller container)
When I run job - new container is created (with given image - image 'eclipse-temurin:11'
When i exec into this new agent container - java --version return expected results.
My job run and run (infinity - didnt wait more than 10 min)
Logs:
Jenkins does not seem to be running inside a container
$ docker run -t -d -u 0:0 -w /var/jenkins_home/workspace/test-1.1 -v /var/jenkins_home/workspace/test-1.1:/var/jenkins_home/workspace/test-1.1:rw,z -v /var/jenkins_home/workspace/test-1.1#tmp:/var/jenkins_home/workspace/test-1.1#tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** eclipse-temurin:11 cat
$ docker top 6d738c52e04050b008d07e19ef4d917ae3350771e2e12d62db780c97879a25f7 -eo pid,comm
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Check versions)
[Pipeline] sh
Sending interrupt signal to process
Aborted by admin
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
$ docker stop --time=1 6d738c52e04050b008d07e19ef4d917ae3350771e2e12d62db780c97879a25f7
$ docker rm -f 6d738c52e04050b008d07e19ef4d917ae3350771e2e12d62db780c97879a25f7
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
It crash on running first Stage - I think that Jenkins agent container cant run pipeline commands.
How to do this? Is there something wrong with my Jenkins configuration?
Btw. working on linux
I am trying to translate a document from .md format to .pdf format with pandoc in github-actions CI (using docker://pandoc/latex:2.14.1).
- uses: docker://pandoc/latex:2.14.1
with:
args: --pdf-engine=xelatex -V mainfont='Times New Roman' report.md -o report.pdf
and I get the error:
/usr/bin/docker run --name pandoclatex2141_eb4592 --label c9e036 --workdir /github/workspace --rm -e INPUT_ARGS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/lab-template/lab-template":"/github/workspace" pandoc/latex:2.14.1 --pdf-engine=xelatex -V mainfont='Times New Roman' report.md -o report.pdf
pandoc: New: openBinaryFile: does not exist (No such file or directory)
But, if I do not specify -V mainfont='Times New Roman', then everything works fine...
I'm trying execute a Jenkins Pipeline that runs a simple ansible playbook.
Ansible is installled and configured on Global Tool Configuration.
Ansible --version
Global Tool Configuration Jenkins
"PATH" Variable
Jenkins Pipeline:
Pipeline calling playbook function
I get the following message when try execute the pipeline.
[pipeline-maven-project] $ docker exec --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** 5c3dd29434b00c89b12637ee632e805b1987bd8934f6d9d95f4d90b755834237 ansible-playbook /var/lib/jenkins/workspace/pipeline-maven-project/playbook.yml
OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: \"ansible-playbook\": executable file not found in $PATH": unknown
FATAL: command execution failed
hudson.AbortException: Ansible playbook execution failed
at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:262)
at org.jenkinsci.plugins.ansible.workflow.AnsiblePlaybookStep$AnsiblePlaybookExecution.run(AnsiblePlaybookStep.java:430)
at org.jenkinsci.plugins.ansible.workflow.AnsiblePlaybookStep$AnsiblePlaybookExecution.run(AnsiblePlaybookStep.java:351)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:367)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Ansible playbook execution failed
So from begin I was trying to link the microblog from here by using next commands:
sudo docker build -t microblog:latest .
sudo docker run --name mysql -d -e MYSQL_RANDOM_ROOT_PASSWORD=yes \
-e MYSQL_DATABASE=microblog -e MYSQL_USER=microblog \
-e MYSQL_PASSWORD=onion~12 \
mysql/mysql-server:5.7
sudo docker run --name elasticsearch -d -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
docker.elastic.co/elasticsearch/elasticsearch-oss:7.6.2
sudo docker run --name microblog -d -p 8000:5000 -e SECRET_KEY=my-secret-key \
-e MAIL_SERVER=smtp.googlemail.com -e MAIL_PORT=587 -e MAIL_USE_TLS=true \
-e MAIL_USERNAME=admin_onion123#gmail.com -e MAIL_PASSWORD=123456780 \
--link mysql:dbserver \
-e DATABASE_URL=mysql+pymysql://microblog:onion~12#dbserver/microblog \
--link elasticsearch:elasticsearch \
-e ELASTICSEARCH_URL=http://elasticsearch:9200 \
microblog:latest
Up here everything is perfect!
Now I was getting the docker container with Tor Hidden-Service from here by using next command:
sudo docker run -itd --link microblog goldy/tor-hidden-service
The ideea is when I am using the command :
sudo docker logs {container of tor}
is showing me the myrandomoninonaddress.onoin:5000.
What I did wrong or what I have missed and why is listening port 5000 instead of 8000?
I am running Jenkins 2.190.1 installed on a Linux Ubuntu LTD 18.04. I just tested the sample code in the Jenkins Guided Tour: https://jenkins.io/doc/pipeline/tour/hello-world/
In concrete my Jenkinsfile is as follows:
pipeline {
agent { docker { image 'maven:3.3.3' } }
stages {
stage('build') {
steps {
sh 'mvn --version'
}
}
}
}
This is the output that I receive in the jenkins console log:
$ docker run -t -d -u 122:127 -w /var/lib/jenkins/workspace/Tutorial -v /var/lib/jenkins/workspace/Tutorial:/var/lib/jenkins/workspace/Tutorial:rw,z -v /var/lib/jenkins/workspace/Tutorial#tmp:/var/lib/jenkins/workspace/Tutorial#tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** maven:3-alpine cat
$ docker top f7771c51c24b1a4d283f327c2ac26959f649f253778f53d65caa94edb0f35cfc -eo pid,comm
[Pipeline] {
[Pipeline] sh
process apparently never started in /var/lib/jenkins/workspace/Tutorial#tmp/durable-74c26f6c
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
[Pipeline] }
$ docker stop --time=1 f7771c51c24b1a4d283f327c2ac26959f649f253778f53d65caa94edb0f35cfc
$ docker rm -f f7771c51c24b1a4d283f327c2ac26959f649f253778f53d65caa94edb0f35cfc
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE