Sunita
Actually i have redo that agent thing i kept it as it is the below is my jenkinsfile but the error is still the same its not getting the git
pipeline {
agent {
docker {
image 'abhishekf5/maven-abhishek-docker-agent:v1'
args '--user root -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon
}
}
stages {
stage('Checkout') {
steps {
sh 'echo passed'
//git branch: 'main', url: 'github.com/sunitabachhav2007/Jenkins-Zero-To-Hero…
}
}
stage('Build and Test') {
steps {
sh 'ls -ltr'
// build the project and create a JAR file
sh 'cd java-maven-sonar-argocd-helm-k8s/spring-boot-app && mvn clean package'
}
}
stage('Static Code Analysis') {
environment {
SONAR_URL = "http://35.172.186.121:9000"
}
steps {
withCredentials([string(credentialsId: 'sonarqube', variable: 'SONAR_AUTH_TOKEN')]) {
sh 'cd java-maven-sonar-argocd-helm-k8s/spring-boot-app && mvn sonar:sonar -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.host.url=${SONAR_URL}'
}
}
}
stage('Build and Push Docker Image') {
environment {
DOCKER_IMAGE = "ashishm95/ultimate-cicd:${BUILD_NUMBER}"
// DOCKERFILE_LOCATION = "java-maven-sonar-argocd-helm-k8s/spring-boot-app/Dockerfile"
REGISTRY_CREDENTIALS = credentials('docker-cred')
}
steps {
script {
sh 'cd java-maven-sonar-argocd-helm-k8s/spring-boot-app && docker build -t ${DOCKER_IMAGE} .'
def dockerImage = docker.image("${DOCKER_IMAGE}")
docker.withRegistry('index.docker.io/v1/& "docker-cred") {
dockerImage.push()
}
}
}
}
stage('Update Deployment File') {
environment {
GIT_REPO_NAME = "Jenkins-integration"
GIT_USER_NAME = "Hawk-95"
}
steps {
withCredentials([string(credentialsId: 'github', variable: 'GITHUB_TOKEN')]) {
sh '''
git config user.email "mondalashish74@gmail.com"
git config user.name "Hawk-95"
BUILD_NUMBER=${BUILD_NUMBER}
sed -i -e "s/ultimate-cicd.*/ultimate-cicd:${BUILD_NUMBER}/g" java-maven-sonar-argocd-helm-k8s/spring-boot-app-manifests/deployment.yml
git add java-maven-sonar-argocd-helm-k8s/spring-boot-app-manifests/deployment.yml
git commit -m "Update deployment image to version ${BUILD_NUMBER}"
git push github.com/$%7BGIT_USER_NAME%7D/$%7BGIT_REPO_NAME… HEAD:main
'''
}
}
}
}
}
error
Started by user Ashish Mondal
Obtained java-maven-sonar-argocd-helm-k8s/spring-boot-app/JenkinsFile from git github.com/Hawk-95/Jenkins-integration.git
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/jenkins-git-intigration
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
No credentials specified
git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/jenkins-git-intigration/.git # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url github.com/Hawk-95/Jenkins-integration.git # timeout=10
Fetching upstream changes from github.com/Hawk-95/Jenkins-integration.git
git --version # timeout=10
git --version # 'git version 2.34.1'
git fetch --tags --force --progress -- github.com/Hawk-95/Jenkins-integration.git +refs/heads/:refs/remotes/origin/ # timeout=10
git rev-parse refs/remotes/origin/main^{commit} # timeout=10
Checking out Revision a3526aec3aa9886f89e5d46286ba2af7f2b49080 (refs/remotes/origin/main)
git config core.sparsecheckout # timeout=10
git checkout -f a3526aec3aa9886f89e5d46286ba2af7f2b49080 # timeout=10
Commit message: "Update deployment.yml"
git rev-list --no-walk a3526aec3aa9886f89e5d46286ba2af7f2b49080 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
- docker inspect -f . abhishekf5/maven-abhishek-docker-agent:v1
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/container… dial unix /var/run/docker.sock: connect: permission denied
[Pipeline] isUnix
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
- docker pull abhishekf5/maven-abhishek-docker-agent:v1
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/cr… dial unix /var/run/docker.sock: connect: permission denied
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE