greenkeeperio / greenkeeper-lockfile

:lock: Your lockfile, up to date, all the time
https://greenkeeper.io
182 stars 73 forks source link

Configure Greenkeeper with Jenkins #158

Closed albert-olive closed 6 years ago

albert-olive commented 6 years ago

Hi,

I have a jenkins job and I'm trying to configure Greenkeeper. This is what I have so far:

def unitTest(){
  node(node_name){
    stage ("Unit test",params.rollBackBuild){
      checkout scm
      echo "Running unit test for brench: ${branch_type}"
      sh 'yarn install'
      sh 'yarn global add greenkeeper-lockfile@1'
      sh 'greenkeeper-lockfile-update'
      sh 'yarn lint'
      sh 'CI=true yarn test'
      sh 'CI=true yarn test:upload'
      sh 'greenkeeper-lockfile-upload'
    }
  }
}

And the console log:

[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "greenkeeper-lockfile@1.15.1" with binaries:
      - greenkeeper-lockfile-update
      - greenkeeper-lockfile-upload
      - greenkeeper-shrinkwrap-update
      - greenkeeper-shrinkwrap-upload
Done in 0.74s.
[Pipeline] sh
[B2B-pippeline_PR-29-BJTQZZUE5OBR55S2FIYCXGSYOM2SZQCPIWQLZOUG4ULLGHHQCURQ] Running shell script
+ greenkeeper-lockfile-update
/home/jenkins/workspace/B2B-pippeline_PR-29-BJTQZZUE5OBR55S2FIYCXGSYOM2SZQCPIWQLZOUG4ULLGHHQCURQ@tmp/durable-b8f0feb2/script.sh: line 2: greenkeeper-lockfile-update: command not found

Do you know why it's happening?

Thanks

janl commented 6 years ago

Looks like wherever yarn add global puts the gk-lockfile binaries is not in the PATH for the shell that execute your steps in the stage.

albert-olive commented 6 years ago

Yes, I ended up doing this:

def unitTest(){
  node(node_name){
    stage ("Unit test",params.rollBackBuild){
      checkout scm
      echo "Running unit test for brench: ${branch_type}"
      sh 'yarn install'
      sh 'yarn add greenkeeper-lockfile@1 --dev'
      sh './node_modules/.bin/greenkeeper-lockfile-update'
      sh 'yarn lint'
      sh 'CI=true yarn test'
      sh 'CI=true yarn test:upload'
      sh './node_modules/.bin/greenkeeper-lockfile-upload'
    }
  }
}

thanks!