mardi 29 mai 2018

Jenkinsfile with Docker: resuse the same Docker container

I can't figure out nor find any Jenkins docs explaining how to achieve that. So I'm using Declarative PIpeline syntax to pull node:9and install the project dependencies:

#Jenkinsfile

#!/usr/bin/env groovy
pipeline {
  // Use always Docker agent for build
  agent {
      docker { image 'node:9' }
  }

stages {
    stage('Install') {
      steps {
        sh 'node --version'
        sh 'yarn --version'
        sh "yarn install --no-cache --frozen-lockfile;"
      }
    }

This works, - I have the right node and yarn versions installed.

Now when I try to add another stage to compile the assets:

#Jenkinsfile
...
stage('Build') {
      steps {
        script {
          docker.image("node:9").inside("-u 0") {
            //sh "${ember} deploy development"
            sh "${ember} deploy build --verbose"
          }
        }
      }
    }

it fails as if Jenkins can't find docker:

Running shell script
+ docker pull node:9
/opt/jenkins_data/workspace/decastore-front@tmp/durable-24c414d8/script.sh: 2: /opt/jenkins_data/workspace/decastore-front@tmp/durable-24c414d8/script.sh: docker: not found

What's wrong here ?




Aucun commentaire:

Enregistrer un commentaire