Search code examples
dockerjenkinsnexussonatype

Error parsing reference: is not a valid repository/tag: invalid reference format


Im trying to make a jenkins pipline that clones code from git and build a docker image then push it to nexus registry so thats what in my jenkins file :

pipeline{
    agent any

    environment{
        DOCKERHUB_CREDENTIALS=credentials('docker_hub')
        NEXUS_CREDENTIALS = credentials('nexus')
        
    }

    stages{
        
        stage('Build'){

            steps{
                sh 'docker build -t my-app .'
            }

        }

        stage('Login'){
            steps{
                sh 'echo $NEXUS_CREDENTIALS_PSW | docker login -u $NEXUS_CREDENTIALS_USR --password-stdin http://localhost:8095/repository/docker-private-repo/'
            }

        }
        stage('Push'){

            steps{
                sh 'docker tag my-app:latest http://localhost:8095/docker-private-repo/my-app:latest'
                sh 'docker push http://localhost:8095/docker-private-repo/my-app:latest'
            }

        }
    }
    post{
        always{
            sh 'docker logout'
        }
    }
}

for cloning the git code im using pipeline SCM , anyway the build stage and login stage are working fine but for the pushing stage i get this error "Error parsing reference: "http://localhost:8095/docker-private-repo/my-app:latest" is not a valid repository/tag: invalid reference format" i dont know what wrong with the tag command ? how can i solve this ?


Solution

  • I Had to remove https:// from the url now it works fine