0
最近,我試圖通過Jenkins使用nodejs 6,7和8來構建nodejs項目。Jenkins:無法在單一版本中構建nodejs的不同版本
我已經安裝了管道NPM集成插件。在Jenkins>全局工具配置,我已經添加了不同版本的nodejs。
但是,當我生成項目,它只有在建立版本的NodeJS 6.這是我Jenkinsfile的內容。
#!/usr/bin/env groovy
pipeline {
agent any
stages {
stage('Build') {
steps {
nodejs('Chill') {
sh 'node --version'
sh 'npm --version'
sh 'yarn --version'
sh 'yarn'
sh 'yarn build'
}
}
}
stage('Test') {
steps {
nodejs('Chill') {
sh 'yarn test'
}
}
}
stage('Deploy') {
steps {
nodejs('Chill') {
}
}
}
}
}
這是構建的日誌文件。
Started by user Sumit Rai
Obtained Jenkinsfile from git https://github.com/srekcahrai/chill.git
[Pipeline] node
Running on 10.10.0.143 in /home/jenkins-client/jenkins/workspace/Chill SCM
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/srekcahrai/chill.git # timeout=10
Fetching upstream changes from https://github.com/srekcahrai/chill.git
> git --version # timeout=10
> git fetch --tags --progress https://github.com/srekcahrai/chill.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 52fb0d17de1a3a2f25292443ee6038d10e22953e (refs/remotes/origin/master)
Commit message: "Added Deploy stage"
> git config core.sparsecheckout # timeout=10
> git checkout -f 52fb0d17de1a3a2f25292443ee6038d10e22953e
> git rev-list 52fb0d17de1a3a2f25292443ee6038d10e22953e # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] nodejs
[Pipeline] {
[Pipeline] sh
[Chill SCM] Running shell script
+ node --version
v6.11.2
[Pipeline] sh
[Chill SCM] Running shell script
+ npm --version
3.10.10
[Pipeline] sh
[Chill SCM] Running shell script
+ yarn --version
0.27.5
[Pipeline] sh
[Chill SCM] Running shell script
+ yarn
yarn install v0.27.5
[1/4] Resolving packages...
success Already up-to-date.
$ npm run build
> [email protected] build /home/jenkins-client/jenkins/workspace/Chill SCM
> run-s lint clean babel
> [email protected] lint /home/jenkins-client/jenkins/workspace/Chill SCM
> eslint src test
> [email protected] clean /home/jenkins-client/jenkins/workspace/Chill SCM
> rimraf dist/
> [email protected] babel /home/jenkins-client/jenkins/workspace/Chill SCM
> babel src/ -d dist/
src/cli/index.js -> dist/cli/index.js
src/common/messages.js -> dist/common/messages.js
src/config/config.js -> dist/config/config.js
src/config/default.config.js -> dist/config/default.config.js
src/index.js -> dist/index.js
src/migrations/20170515111050_create_status_logs_table.js -> dist/migrations/20170515111050_create_status_logs_table.js
src/models/StatusLog.js -> dist/models/StatusLog.js
src/monitoring/Monitor.js -> dist/monitoring/Monitor.js
src/monitoring/eventListener.js -> dist/monitoring/eventListener.js
src/monitoring/init.js -> dist/monitoring/init.js
src/services/email.js -> dist/services/email.js
src/services/events.js -> dist/services/events.js
src/services/hipchat.js -> dist/services/hipchat.js
src/services/notifier.js -> dist/services/notifier.js
src/services/persistence.js -> dist/services/persistence.js
src/services/slack.js -> dist/services/slack.js
src/services/status.js -> dist/services/status.js
src/services/twilio.js -> dist/services/twilio.js
src/services/websocket.js -> dist/services/websocket.js
src/utils/db.js -> dist/utils/db.js
src/utils/emailRenderer.js -> dist/utils/emailRenderer.js
src/utils/http.js -> dist/utils/http.js
src/utils/logger.js -> dist/utils/logger.js
src/utils/string.js -> dist/utils/string.js
src/utils/websocketServer.js -> dist/utils/websocketServer.js
Done in 11.21s.
[Pipeline] sh
[Chill SCM] Running shell script
+ yarn build
yarn build v0.27.5
$ run-s lint clean babel
> [email protected] lint /home/jenkins-client/jenkins/workspace/Chill SCM
> eslint src test
> [email protected] clean /home/jenkins-client/jenkins/workspace/Chill SCM
> rimraf dist/
> [email protected] babel /home/jenkins-client/jenkins/workspace/Chill SCM
> babel src/ -d dist/
src/cli/index.js -> dist/cli/index.js
src/common/messages.js -> dist/common/messages.js
src/config/config.js -> dist/config/config.js
src/config/default.config.js -> dist/config/default.config.js
src/index.js -> dist/index.js
src/migrations/20170515111050_create_status_logs_table.js -> dist/migrations/20170515111050_create_status_logs_table.js
src/models/StatusLog.js -> dist/models/StatusLog.js
src/monitoring/Monitor.js -> dist/monitoring/Monitor.js
src/monitoring/eventListener.js -> dist/monitoring/eventListener.js
src/monitoring/init.js -> dist/monitoring/init.js
src/services/email.js -> dist/services/email.js
src/services/events.js -> dist/services/events.js
src/services/hipchat.js -> dist/services/hipchat.js
src/services/notifier.js -> dist/services/notifier.js
src/services/persistence.js -> dist/services/persistence.js
src/services/slack.js -> dist/services/slack.js
src/services/status.js -> dist/services/status.js
src/services/twilio.js -> dist/services/twilio.js
src/services/websocket.js -> dist/services/websocket.js
src/utils/db.js -> dist/utils/db.js
src/utils/emailRenderer.js -> dist/utils/emailRenderer.js
src/utils/http.js -> dist/utils/http.js
src/utils/logger.js -> dist/utils/logger.js
src/utils/string.js -> dist/utils/string.js
src/utils/websocketServer.js -> dist/utils/websocketServer.js
Done in 9.35s.
[Pipeline] }
[Pipeline] // nodejs
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] nodejs
[Pipeline] {
[Pipeline] sh
[Chill SCM] Running shell script
+ yarn test
yarn test v0.27.5
$ NODE_ENV=test mocha
Chill 1.0.0-alpha.2 - Test SuiteLoading config file: chill.test.yml
cli
--version
chill 1.0.0-alpha.2
✓ should print the chill cli version (1477ms)
--help
Usage: chill [options]
Options:
-h, --help Show help [boolean]
-c, --config Configuration file path.
-V, --version Show version number [boolean]
✓ should print the chill usage help string (1468ms)
config.get
✓ should return the previously resolved config from the cache.
config.resolve
Loading config file: function() { [native code] }
✓ should return default configuration even if the config file is empty.
Loading config file: function() { [native code] }
✓ should merge and return both the config loaded from file and the default ones.
Loading config file: function() { [native code] }
✓ should return the resolved config that overrides the default values if same keys are found.
Loading config file: Glens
✓ should put the resolved config in the cache.
Monitor.handleStatusChange
✓ should trigger the EVENT_STATUS_CHANGED event.
Monitor.isStatusDifferent
✓ should return true if status is different.
✓ should return false if status is same.
Monitor.start
✓ should trigger the EVENT_MONITORING_STARTED event.
email.isEnabled
✓ should return true if email notification is enabled.
✓ should return false if email notification is not enabled.
Unhandled rejection AssertionError: expected 'Investment Account' to equal 'digital'
at EventEmitter.<anonymous> (/home/jenkins-client/jenkins/workspace/Chill SCM/test/monitoring/Monitor.handleStatusChange.test.js:24:14)
at Object.invoke (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/sinon/lib/sinon/behavior.js:140:32)
at EventEmitter.functionStub (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/sinon/lib/sinon/stub.js:83:53)
at Function.invoke (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/sinon/lib/sinon/spy.js:194:51)
at EventEmitter.proxy (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/sinon/lib/sinon/spy.js:97:22)
at emitOne (events.js:96:13)
at EventEmitter.emit (events.js:188:7)
at Object.trigger (/home/jenkins-client/jenkins/workspace/Chill SCM/src/services/events.js:16:11)
at Monitor.handleStatusChange (/home/jenkins-client/jenkins/workspace/Chill SCM/src/monitoring/Monitor.js:69:12)
at Monitor._callee2$ (/home/jenkins-client/jenkins/workspace/Chill SCM/src/monitoring/Monitor.js:47:12)
at tryCatch (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/regenerator-runtime/runtime.js:65:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/regenerator-runtime/runtime.js:303:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/regenerator-runtime/runtime.js:117:21)
at step (/home/jenkins-client/jenkins/workspace/Chill SCM/src/monitoring/Monitor.js:31:191)
at /home/jenkins-client/jenkins/workspace/Chill SCM/src/monitoring/Monitor.js:31:361
at tryCatcher (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/home/jenkins-client/jenkins/workspace/Chill SCM/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
email.getClient
✓ should create a nodemailer transport with provided configurations
email.notify
✓ should send email notification with correct parameters.
hipchat.isEnabled
✓ should return true if hipchat notification is enabled.
✓ should return false if hipchat notification is not enabled.
hipchat.notify
✓ should send the notification payload to the hipchat API endpoint.
✓ should log error if it fails to send notification to hipchat.
notifier.notify
✓ should notify if slack is enabled
✓ should not notify if slack is not enabled
persistence.persist
✓ should persist status log to database.
✓ should log an error if it cannot persist to database.
persistence.getLastStatus
✓ should get last status of service from database.
✓ should return null if it cannot get last status of service from database.
✓ should log an error if it cannot fetch from database.
slack.isEnabled
✓ should return true if slack notification is enabled.
✓ should return false if slack notification is not enabled.
slack.notify
✓ should send the notification payload to the slack API endpoint.
✓ should log error if it fails to send notification to slack.
status.getCheckInterval
✓ should return maximum interval if status is up.
✓ should return minimum interval if status is down.
center
✓ would return the text centered with left-padding slightly less than the right-padding if width is even and text length is odd.
✓ would return the text centered with left-padding slightly less than the right-padding if width is odd and text length is even.
✓ should return the text centered with equal padding on both sides if the width and text length are both odd numbers.
✓ should return the text centered with equal padding on both sides if the width and text length are both even numbers.
✓ should return the same text if the width is less than or equal to the text length.
✓ should return the centered text with custom fillchar too.
twilio.isEnabled
✓ should return true if twilio notification is enabled.
✓ should return false if twilio notification is not enabled
twilio.notify
✓ should send notification from twilio with correct params
✓ should log error when twilio fails to send the message
websocket.isEnabled
✓ should return true if websocket notification is enabled.
✓ should return false if websocket notification is not enabled.
websocket.init
✓ should initialize websocket server if websocket is enabled.
✓ should not initialize websocket server if websocket is disabled.
websocket.notify
✓ should broadcast to all clients.
47 passing (3s)
Done in 6.85s.
[Pipeline] }
[Pipeline] // nodejs
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy)
[Pipeline] nodejs
[Pipeline] {
[Pipeline] }
[Pipeline] // nodejs
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
特拉維斯,同樣的過程是由
language: node_js
node_js:
- "8"
- "7"
- "6"
before_script:
- yarn build
script:
- yarn test
我很困惑,無論是在插件的錯誤,因爲該插件允許的NodeJS的多個版本,或我應該手動提及他們做在Jenkinsfile中。
這是你需要在本節來定義你的工具的例子,你的情況是節點「節點安裝名」 –
需要行家,我不認爲。但我想 工具{ 的NodeJS '寒意' } 但有沒有在日誌 [管道] //階段 [管道]階段 [管道] {(聲明:工具安裝) [管道]工具 [管道] envVarsForTool [管道]} – srekcahrai