jenkinsci / npm-yarn-wrapper-steps-plugin

A Jenkins plugin for convenient usage of npm and yarn in pipelines
https://plugins.jenkins.io/npm-yarn-wrapper-steps/
MIT License
2 stars 2 forks source link

Command not recognised/NullPointer error #4

Closed riskydissonance closed 3 years ago

riskydissonance commented 3 years ago

Version report

Jenkins and plugins versions report:

Jenkins: 2.289.1
OS: Linux - 5.4.0-73-generic
---
pipeline-model-extensions:1.8.4
token-macro:2.15
workflow-multibranch:2.24
ace-editor:1.1
pipeline-input-step:2.12
nexus-jenkins-plugin:3.11.20210420-142258.bdfc332
npm-yarn-wrapper-steps:0.0.2
blueocean-core-js:1.24.7
sse-gateway:1.24
bouncycastle-api:2.20
echarts-api:5.1.0-2
variant:1.4
blueocean-commons:1.24.7
jdk-tool:1.5
plugin-util-api:2.2.0
blueocean:1.24.7
workflow-basic-steps:2.23
github-branch-source:2.10.4
sonar:2.13.1
pubsub-light:1.14
blueocean-pipeline-editor:1.24.7
blueocean-jwt:1.24.7
blueocean-web:1.24.7
timestamper:1.13
structs:1.23
docker-workflow:1.26
antisamy-markup-formatter:2.1
workflow-scm-step:2.12
blueocean-i18n:1.24.7
blueocean-events:1.24.7
blueocean-pipeline-scm-api:1.24.7
blueocean-rest:1.24.7
matrix-project:1.19
external-monitor-job:1.7
jjwt-api:0.11.2-9.c8b45b8bb173
blueocean-autofavorite:1.2.4
github-api:1.123
pipeline-graph-analysis:1.11
workflow-step-api:2.23
theme-manager:0.6
script-security:1.77
apache-httpcomponents-client-4-api:4.5.13-1.0
blueocean-github-pipeline:1.24.7
htmlpublisher:1.25
workflow-api:2.42
jenkins-design-language:1.24.7
material-theme:0.3.3
blueocean-rest-impl:1.24.7
favorite:2.3.3
matrix-auth:2.6.7
nvm-wrapper:0.1.7
junit:1.50
pipeline-stage-step:2.5
pipeline-stage-tags-metadata:1.8.4
scm-api:2.6.4
blueocean-pipeline-api-impl:1.24.7
display-url-api:2.3.5
branch-api:2.6.4
blueocean-display-url:2.4.1
github:1.33.1
popper-api:1.16.1-2
credentials:2.5
handy-uri-templates-2-api:2.1.8-1.0
durable-task:1.37
workflow-cps:2.92
jackson2-api:2.12.3
built-on-column:1.1
font-awesome-api:5.15.3-2
trilead-api:1.0.13
blueocean-config:1.24.7
msbuild:1.30
blueocean-bitbucket-pipeline:1.24.7
ant:1.11
command-launcher:1.6
git-client:3.7.2
jquery3-api:3.6.0-1
configuration-as-code:1.51
git:4.7.2
jquery:1.12.4-1
slack:2.48
credentials-binding:1.25
build-timeout:1.20
docker-commons:1.17
bootstrap4-api:4.6.0-3
sshd:3.0.3
javadoc:1.6
git-server:1.9
okhttp-api:3.14.9
git-parameter:0.9.13
snakeyaml-api:1.27.0
workflow-cps-global-lib:2.19
workflow-support:3.8
pam-auth:1.6
resource-disposer:0.15
ldap:2.7
gitlab-plugin:1.5.20
workflow-durable-task-step:2.39
workflow-job:2.41
mailer:1.34
cloudbees-bitbucket-branch-source:2.9.9
windows-slaves:1.8
caffeine-api:2.9.1-23.v51c4e2c879c8
authentication-tokens:1.4
blueocean-personalization:1.24.7
ws-cleanup:0.39
blueocean-git-pipeline:1.24.7
pipeline-build-step:2.13
plain-credentials:1.7
jsch:0.1.55.2
checks-api:1.7.0
cloudbees-folder:6.15
pipeline-model-definition:1.8.4
ssh-credentials:1.19
pipeline-model-api:1.8.4
pipeline-milestone-step:1.3.2
blueocean-dashboard:1.24.7
Jenkins: Docker jenkins/jenkins:2.289.1-lts
Agent: Websockets runner on `5.4.0-73-generic #82-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux`

Reproduction steps

Trying to run yarn commands from a declarative pipelines build, following the documentation at https://plugins.jenkins.io/npm-yarn-wrapper-steps/#documentation I originally I tried this step:

stage('test') {
            steps {
                script {
                    yarn command: 'install --cache-folder .yarn', workspaceSubdirectory 'ui'
                    yarn command: 'lint --fix', workspaceSubdirectory 'ui'
                    yarn command: 'jest --coverage', workspaceSubdirectory 'ui'
                }

            }
        }

But got:

Started by user admin
Obtained Jenkinsfile from git https://<repo>
Running in Durability level: MAX_SURVIVABILITY
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 65: Expected a step @ line 65, column 17.
                   yarn command: 'install --cache-folder .yarn', workspaceSubdirectory 'ui'
                   ^

WorkflowScript: 66: Expected a step @ line 66, column 17.
                   yarn command: 'lint --fix', workspaceSubdirectory 'ui'
                   ^

WorkflowScript: 67: Expected a step @ line 67, column 17.
                   yarn command: 'jest --coverage', workspaceSubdirectory 'ui'
                   ^

3 errors

    at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
    at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
    at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
    at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142)
    at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:571)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:523)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:337)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE

There seemed to be some issue with the workspaceSubdirectory being recognised so changed it to

stage('test') {
            steps {
                script {
                    sh "cd ${env.WORKSPACE}/ui"
                    yarn 'install --cache-folder .yarn'
                    yarn 'lint --fix'
                    yarn 'jest --coverage'
                }

            }
        }

And now get a NullPointer:

...
[Pipeline] End of Pipeline
java.lang.NullPointerException
    at io.interrogate.npmyarnwrappersteps.plugin.NodeStep.setUpNVM(NodeStep.java:54)
    at io.interrogate.npmyarnwrappersteps.plugin.YarnStep.perform(YarnStep.java:48)
    at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:99)
    at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:69)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE

Results

Expected result:

Yarn commands get run successfully,

Actual result:

Errors detailed above.

jameslafferty commented 3 years ago

@m0rv4i The java.NullPointerException should be resolved in version 0.1.0. Thank you for bringing it to my attention!

riskydissonance commented 3 years ago

Legend, thanks!!