Jenkins is only checking out and skipping the remaining stages from my Jenkinsfile

Hi!

This is driving me crazy. We are putting down our current Ubuntu 20.04 CI server that ran all builds, and installed Jenkins on a Debian 10. The same Jenkinsfile that worked perfectly on its predecessor it’s not working now.

Although the Jenkinsfile has 4 stages and a post actions, the server is only doing the first (checkout) and the post actions.

This is the Jenkinsfile:

pipeline {
    agent any
    environment {
        GIT_BRANCH = "origin/${BRANCH_NAME}"
        BRANCH_NAME = "${BRANCH_NAME}"
        REGISTRY_CREDENTIALS = credentials('REDACTED')
        REGISTRY= "REDACTED"
    }

    stages {
        stage ('Checkout') {
            steps {
                checkout scm
            }
        }

        stage ('Build') {
            steps {
                sh '''#!/bin/bash
                cd ci
                
                echo "BRANCH_NAME=$BRANCH_NAME"
                echo "GIT_BRANCH=$GIT_BRANCH"
                
                ./build.sh REDACTED
                '''
            }
        }

        stage ('Push') {
            steps {
                sh '''#!/bin/bash
                cd ci

                echo "Logging in the $REGISTRY registry as $REGISTRY_CREDENTIALS_PSW ..."

                if ( ! docker login -p "$REGISTRY_CREDENTIALS_PSW" -u "$REGISTRY_CREDENTIALS_USR" "$REGISTRY" ) ; then
                        echo "Could not login to ${REGISTRY}. Aborting..."
                        return 1;
                fi

                ./push.sh REGISTRY
                if [ -e alias.sh ] ; then
                    . ./gitinfo.sh
                    ./alias.sh "$TAG" "$BRANCH" REGISTRY
                    ./push.sh --tag "$BRANCH" REGISITRY
                fi
                '''
            }
        }

        stage ('Deploy') {
            steps {
                sh '''#!/bin/bash
                cd ci
                ./deploy.sh "192.168.10.254/cid" REGISTRY
                '''
            }
        }
    }

    post {  
         always {
            emailext attachLog: true,
            body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n",
            subject: "CID Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}",
            to: 'REDACTED'
        }
    }
}

And this is the log, where you can see that after checkout does nothing and build fails:

Branch indexing
 > git rev-parse --resolve-git-dir /var/lib/jenkins/caches/git-0e6e81d299f91559ab810b57e68d4bd2/.git # timeout=10
Setting origin to REDACTED
 > git config remote.origin.url REDACTED # timeout=10
Fetching origin...
Fetching upstream changes from origin
 > git --version # timeout=10
 > git --version # 'git version 2.20.1'
 > git config --get remote.origin.url # timeout=10
using GIT_SSH to set credentials 
 > git fetch --tags --force --progress -- origin +refs/heads/*:refs/remotes/origin/* # timeout=10
Seen branch in repository origin/master
Obtained Jenkinsfile from e59d9a215b4af7a61afbcf027fe0c2f59dc4845f
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/GH_master
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
The recommended git tool is: git
using credential REDACTED
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository REDACTED
 > git init /var/lib/jenkins/workspace/GH_master # timeout=10
Fetching upstream changes from REDACTED
 > git --version # timeout=10
 > git --version # 'git version 2.20.1'
using GIT_SSH to set credentials 
 > git fetch --no-tags --force --progress -- REDACTED +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url REDACTED # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
Checking out Revision e59d9a215b4af7a61afbcf027fe0c2f59dc4845f (master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f e59d9a215b4af7a61afbcf027fe0c2f59dc4845f # timeout=10
Commit message: "Merge branch 'hotfix/remove-static-offer-results'"
First time build. Skipping changelog.
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] emailext
Sending email to: REDACTED
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
ERROR: 52bd6302-9db7-437b-8183-741ea068b4d9
Finished: FAILURE

Why is now the server skipping all the build stages?

Something is failing.

My guess is the checkout scm because I don’t see the second stage started. You don’t need that step though, declarative pipelines (ones that start with pipeline {) automatically checkout code so your just doing double the work.

Its also possible its the environment variables, I’m not sure what BRANCH_NAME would be at the start of your job if your not using multibranch pipelines. It may fail when trying to parse the first sh statement then?

The UUID error is unusual; can you have a look the log of the Jenkins controller (of the java process?)

I’m very sorry! I did not get any notifications of these responses. Thank you very much for responding.

The thing is that this file works well with the old servers. And there is no difference in the configurations, I’ve checked that it’s indeed a multibranch pipeline.

I’ll retry the build without the checkout step and see how that plays out :slight_smile:

I’ not really sure how to do that, but I’ll try :smiley:

Mistery solved

This error it’s caused by the new server trying to use a credential ID that no longer exists. Once changed to the new one, the pipeline worked like charm :slight_smile:

Thanks a lot

Probably should report that to the issue tracker, could be a better error message.