Home > Enterprise >  No credentials specified Fetching changes from the remote Git
No credentials specified Fetching changes from the remote Git

Time:09-17

I'm trying to do my first Jenkins job. I want to run a java project that uploaded to git but I get this error while building the job:


No credentials specified Fetching changes from the remote Git repository ERROR: Error fetching remote repo 'origin' hudson.plugins.git.GitException: Failed to fetch from https://gitlab/engineering/automation/create_pass_criteria.git at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:908) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1123) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1159) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://gitlab/engineering/automation/create_pass_criteria.git refs/heads/:refs/remotes/origin/" returned status code 128: stdout: stderr: fatal: unable to access 'https://gitlab/engineering/automation/create_pass_criteria.git/': Peer's certificate issuer has been marked as not trusted by the user.


This is my groovy jenkinsfile:

#!groovy

pipeline {
    agent { node { label "agent_314" } }

    stages {

        stage("Build") {
            steps {
                echo "Building..."
                git 'https://gitlab/engineering/automation/create_pass_criteria.git'
                sh './mvnw clean compile'
            }
          }
      }
    }

CodePudding user response:

Add credentials in Jenkins for your git repository and then supply the credentials in pipeline for git checkout

To Add credentials - Jenkins -> Manage Jenkins ->Manage Credentials Under Stores scoped to Jenkins , click on Jenkins then click on Global Credentials (unrestricted) .

From left side click on Add Credentials and Define the username and password for your git repository and note down credentialsID

Add below line in your jenkinsfile

git credentialsId: 'your git credentials ID', url: 'https://gitlab/engineering/automation/create_pass_criteria.git'

For more information you can refer here

  • Related