Tagging Stage in Jenkins

Viewed 11
I have generated ssh key and added public key in gitlab and private ssh key in Jenkins as secret file with Id: 'abc'. I also have added same ssh private ssh key in Jenkins as username with ssh key with Id: "abc-git". 

I am getting error as + cp **** /var/lib/jenkins/.ssh/ cp: cannot create regular file '/var/lib/jenkins/.ssh/rsa-key': Permission denied

stage('Tagging') {
            when {
                anyOf {
                    branch 'develop';
                }
            }
            steps {
                withCredentials([file(credentialsId: 'abc', variable: 'FILE')]) {
                    sh 'cp $FILE ~/.ssh/'
                }
                git credentialsId: "abc-git", url: 'ssh://git@git.gitlab.com/test-pipeline.git', branch: "develop"
                sh "git config --global user.email 'xyz@gmail.com' && git config --global user.name 'PQR'"
                sh './git_release.sh'
            }
            post {
                success {
                    updateGitlabCommitStatus name: STAGE_NAME, state: 'success'
                }
                failure {
                    updateGitlabCommitStatus name: STAGE_NAME, state: 'failed'
                }
                aborted {
                    updateGitlabCommitStatus name: STAGE_NAME, state: 'canceled'
                }
            }
1 Answers

ls all files in this directory for confirm is correct or not

Related