Okay so I have successfully established the connection between Jenkins and Bitbucket server but I'm having issues getting into the directory on the ec2 server where I have cloned my bitbucket repo>
Below is my script and Jenkins Console output
pipeline {
agent any
stages {
stage('Checkout Git Repository') {
steps {
// Set up the checkout directory
sh 'cd /var/lib/jenkins/test'
sh 'git status'
sh 'ls -la /var/lib/jenkins'
// Check out the current branch of the Git repository
dir('/home/ec2-user/Sona-Grafana/BitBucket-Repo/observability/soc-poc') {
git url: 'https://[email protected]/emmanuel-sona/soc-jenkins.git'
}
}
}
I cannot cd into /home/ec2-user/Sona-Grafana/BitBucket-Repo/observability/soc-poc. It only allows me entry into /var/lib/jenkins/test
Docker-compose file used in spinning up the Jenkins server that runs on the EC2 instance
version: '3'
services:
jenkins:
container_name: ops_jenkins_server
image: jenkins/jenkins:lts-jdk11
ports:
- "8080:8080"
volumes:
- jenkins_home:/var/jenkins_home
- /opt/jenkins_container_volume:/var
- /home/ec2-user/Sonalake-Grafana/BitBucket-Repo/observability/soc-poc:/var/lib/jenkins
environment:
- JENKINS_OPTS="--httpPort=8080"
- JAVA_OPTS="-Djenkins.install.runSetupWizard=false"
docker:
image: docker:latest
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
volumes:
jenkins_home:
networks:
default:
driver: bridge