jenkins 管道不在 dockerhub 中拉图像

问题描述

jenkins 不拉图像。我正在使用窗户。我正在运行 jenkins 作为容器。我收到以下错误。如果你能帮助我,我会很高兴。

    node {
    def commit_id
    stage('Preparation') {
    checkout scm
    sh "git rev-parse --short HEAD > .git/commit_id"
    commit_id = readFile('.git/commit_id').trim()
    }

    stage('test') {
    def myTestContainer = docker.image('node:4.6')
    myTestContainer.pull()
    myTestContainer.inside {
    sh ' npm install --only=dev '
    sh ' npm '

    }}}

enter image description here

解决方法

试试这个:

pipeline {
    agent {
        docker {
            image 'node:4.6'
            label 'agent-name'
        }
    }

    stages {
        stage('test') {
            // your code here
        }
    }
}

agent-name 替换为从代理名称或主代理作为容器的主机。