Created docker compose file with custom image build
services:
jenkins:
# image: jenkins/jenkins:lts-jdk21
image: jenkins-my-img:lts-jdk21
build:
context: .
dockerfile: Dockerfile
container_name: jenkins-server
platform: linux/amd64
ports:
- "8080:8080"
- "50000:50000"
# user: "1000"
# environment:
# - PUID=1000
# - PGID=1000
volumes:
- jenkins_home:/var/jenkins_home:rw
# - ~/jenkins_config:/var/jenkins_home
# agent:
# image: jenkins/ssh-agent:jdk21
# container_name: agent
# privileged: true
# expose:
# - 22
# environment:
# - JENKINS_AGENT_SSH_PUBKEY=${SSH_PUB_KEY}
# # user: root
# volumes:
# - agent_data:/home/jenkins/agent # For persistent agent data
volumes:
jenkins_home:
# agent_data:
Dockerfile:
(had to use custom docker image to install recommended plugins because plugins do not install due to some issue with Java cert store!)
FROM jenkins/jenkins:lts-jdk21
USER root
RUN apt-get update && apt-get install -y ca-certificates && \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN update-ca-certificates
RUN jenkins-plugin-cli --plugins "timestamper ant gradle git ldap mailer github-branch-source ws-cleanup build-timeout credentials-binding pipeline-github antisamy-markup-formatter ssh-agent matrix-auth email-ext pipeline-graph-view pipeline-github-lib dark-theme workflow-aggregator ssh-slaves pam-auth"
USER jenkins
Created Pipeline and ran on jenkins server with issues (file permissions?):
[Security Scan] ERROR: An exception occurred while writing into json file: Failed to create a temp file on /var/jenkins_home/workspace
[Security Scan] ERROR: Workflow failed! Exit code 999: Undefined plugin error - Cannot invoke "String.concat(String)" because "arg" is null
Does the same when try on an ssh agent. Hello world pipeline works.
The pipeline I am running downloads an external CLI utility that tries to write files in the workspace. How do I give it permission? OR is the issue docker compose volume permission?
Any ideas as to how to get jenkins pipelines working and building in docker compose stack?