jenkins-x-buildpacks / jenkins-x-kubernetes

Kubernetes Build Pack extends the Classic Build Pack to add opinionated CI+CD for Kubernetes Environments with GitOps based promotion
Apache License 2.0
83 stars 266 forks source link

javascript buildPack: NPM not available in release/setVersion step #98

Open haysclark opened 4 years ago

haysclark commented 4 years ago

When using the 'buildPack: javascript', I do not have access to npm when I replace the setVersion step of the release pipeline. Additionally, trying to use a customimages in these steps does NOT work either. Ideally, I am trying to overriding-version; but I need access to the npm command, or ideally, an npx command (assuming NodeJS10x or NodeJS12x images worked in the setVersion step).

buildPack: javascript
pipelineConfig:
  agent:
    label: jenkins-nodejs
    container: nodejs
  pipelines:
    release:
      setVersion:
        replace: true
        steps:
          - name: next-version
            sh: which npm
            comment: npm is NOT found in this step.
            # no change even if image is provided, see next line:
            # image: gcr.io/jenkinsxio/builder-nodejs
      build:
        replace: true
        steps:
          - name: npmrc
            sh: which npm
            comment: npm IS found in this step.

Error output:

Showing logs for build mycompany/nodejs-project/master #85 release stage meta-pipeline and container step-create-tekton-crds
running command: which npm
which: no npm in (/opt/apache-maven-3.6.3/bin:/usr/local/git/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/google-cloud-sdk/bin:/opt/google/chrome:/build
er/home/.jx/bin:/builder/home/.jx/maven/bin:/builder/home/.jx/jenkins-x-versions:/builder/home/.jx/bin:/builder/home/.jx/maven/bin:/builder/home/.jx/jenkins-x-versions:/builder/home
/.jx/bin:/builder/home/.jx/maven/bin:/builder/home/.jx/jenkins-x-versions:/builder/home/.jx/bin:/builder/home/.jx/maven/bin:/builder/home/.jx/jenkins-x-versions:/builder/home/.jx/bi
n:/builder/home/.jx/maven/bin:/builder/home/.jx/jenkins-x-versions:/builder/home/.jx/bin:/builder/home/.jx/maven/bin:/builder/home/.jx/jenkins-x-versions:/builder/home/.jx/bin:/buil

der/home/.jx/maven/bin:/workspace/source)
error: failed to set the version on release pipelines: failed to run '/bin/sh -c which npm' command in directory '/workspace/source', output: ''

Pipeline failed on stage 'meta-pipeline' : container 'step-create-tekton-crds'. The execution of the pipeline has stopped.

TLDR;

Despite my best efforts, I'm still struggling to understand how to manipulate a jenkins-x.yml. Part of the confusion is because some elements seem to be mutable, while others are not.

I have done my best to step back through the build packs starting from the kubernetes javascript/pipeline.yaml, which extends classic javascript/pipeline.yaml, which extends the classic pipeline.

It's unclear to me why release/build HAS access to npm, while release/setVersion does not.

Maybe someone can clarify if this is expected behaviour or a bug?

JX Version

~jx version                                                                                                                                                         NAME               VERSION
jx                 2.0.1245

Kubernetes cluster v1.15.8-gke.3
kubectl            v1.15.9
helm client        2.16.1
git                2.17.2 (Apple Git-113)
Operating System   Mac OS X 10.13.6 build 17G12034
haysclark commented 4 years ago

@garethjevans I wanted to ping you about this issue in case you had any insight.