jenkins - 在本地构建和运行良好的 Polymer 项目无法在 Jenkins 上构建并出现“无法加载导入”错误?
问题描述
我有一个使用 polymer-cli 构建的 web 开发项目。在我的本地机器上,当我在项目文件夹中运行聚合物构建时,我能够成功构建项目。
但是,如果我尝试在 Jenkins 上构建项目,则会失败并出现“无法加载导入”错误。这是概述错误的控制台输出
[es_feature_DFWAVPTEAM-20700-N5X7SV3DXUY4RYTUABJZDHFFNKSRTWQBDGZRTEGN3QAI3TVBXF7A] Running shell script
+ docker run --net=host --rm -u 500:500 -w /users/jenkins/workspace/es_feature_DFWAVPTEAM-20700-N5X7SV3DXUY4RYTUABJZDHFFNKSRTWQBDGZRTEGN3QAI3TVBXF7A -v /users/jenkins/workspace/es_feature_DFWAVPTEAM-20700-N5X7SV3DXUY4RYTUABJZDHFFNKSRTWQBDGZRTEGN3QAI3TVBXF7A:/users/jenkins/workspace/es_feature_DFWAVPTEAM-20700-N5X7SV3DXUY4RYTUABJZDHFFNKSRTWQBDGZRTEGN3QAI3TVBXF7A docker-registry.aeg.cloud/iconics/polymer:latest bash -c '
echo
echo -n "POLYMER_VERSION=" && polymer --version && echo -n "BOWER_VERSION=" && bower --version && env
bower install
polymer build
'
POLYMER_VERSION=1.5.4
BOWER_VERSION=1.8.2
HOSTNAME=eptjnksbxmsdc03.ds.dtveng.net
PWD=/users/jenkins/workspace/es_feature_DFWAVPTEAM-20700-N5X7SV3DXUY4RYTUABJZDHFFNKSRTWQBDGZRTEGN3QAI3TVBXF7A
HOME=/home/jenkins
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=/usr/bin/env
info: Clearing build/ directory...
info: (default) Building...
<link rel="import" href="baseline-policy-basic-info.html">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/baseline-policies/baseline-policy-edit.html(5,24) error [could-not-load] - Unable to load import:
error: Promise rejection: Error: 1 error(s) occurred during build.
error: Error: 1 error(s) occurred during build.
at BuildAnalyzer._done (/usr/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:265:36)
at BuildAnalyzer.<anonymous> (/usr/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:225:26)
at Generator.next (<anonymous>)
at fulfilled (/usr/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:17:58)
at process._tickCallback (internal/process/next_tick.js:109:7)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // ansiColor
[Pipeline] echo
script returned exit code 1
这是我的baseline-policy-edit.html 文件:
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../bower_components/dfw-styles/dfw-styles.html">
<link rel="import" href="../../bower_components/dfw-styles/dfw-icon-styles.html">
<link rel="import" href="../../bower_components/paper-button/paper-button.html">
<link rel="import" href="baseline-policy-basic-info.html">
<dom-module id="baseline-policy-edit">
<template>
<style include="dfw-styles dfw-icon-styles">
.bottom-buttons{
padding-top: 10px;
margin: 30px;
border-top: 1px solid #eaeaea;
}
</style>
<!--TODO: have blank canvas element here that will be dynamically filled with polymer element input fields -->
<baseline-policy-basic-info id="common" item-data="{{itemData}}" name="common"></baseline-policy-basic-info>
<div class="buttom-buttons">
<paper-button class="dfw-anchor" on-tap="_backToPolicies">Back to Table</paper-button>
</div>
</template>
<script>
class BaselinePolicyEdit extends Polymer.Element {
static get is() { return 'baseline-policy-edit'; }
static get properties() {
return {
itemData: {
type: Object,
value: {},
notify:true,
observer:"_setupSides"
},
changeView: {
type: Boolean,
value : false,
notify: true,
readOnly : true
}
}
}
static get observers() { }
_setupSides(){
var ia;
var switchItem;
if(this.itemData.hasOwnProperty('header') || this.itemData.hasOwnProperty('newDomain')) {
if(this.itemData.hasOwnProperty('newDomain')) {
switchItem = this.itemData.newDomain;
this.itemData.template = {};
}
else {
switchItem = this.itemData.header.domain;
}
switchItem = switchItem.replace(/[^\w\s]/gi, '').toLowerCase();
//this._splitFields(this.keystores[switchItem]);
}
}
_backToPolicies(){
this.dispatchEvent(new CustomEvent('baseline-policy-view', {bubbles : true, composed : true, detail:{item:true}}));
}
}
customElements.define(BaselinePolicyEdit.is, BaselinePolicyEdit);
</script>
</dom-module>
这是我的baseline-policy-basic-info.html 文件:
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../bower_components/paper-input/paper-input.html">
<link rel="import" href="../../bower_components/paper-item/paper-item.html">
<link rel="import" href="../../bower_components/paper-listbox/paper-listbox.html">
<link rel="import" href="../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<dom-module id="baseline-policy-basic-info">
<template>
<style>
:host {
display: block;
padding: 10px 20px;
}
.basic-info-body{
margin: 30px;
}
paper-dropdown-menu {
--paper-menu-button-dropdown: {
width : 50%;
}
}
paper-dropdown-menu, paper-input {
width : 80%;
display: inline-block;
}
paper-item {
--paper-item-min-height: 36px;
}
</style>
<div class="basic-info-body">
<h1>Basic Information</h1>
<paper-input id="bpName" label="Name" placeholder="Baseline Policy Name"></paper-input>
<paper-input id="bpVersion" label="Version"></paper-input>
<paper-input id="bpDescription" label="Description" placeholder="Describe the context of the baseline policy"></paper-input>
<paper-input id="bpKeywords" label="Keywords" placeholder="Use comma to separate words: HBO, EST, non transactional"></paper-input>
<!-- <paper-input id="bpDomain" label="Domain"></paper-input> -->
<input is="iron-input" name="status" type="hidden" value$="[[statusSelected]]">
<paper-dropdown-menu required label="Status"
no-animations error-message="Selection Required!">
<paper-listbox id="bpStatus" class="dropdown-content" attr-for-selected="value" selected="{{statusSelected}}" slot="dropdown-content">
<template is="dom-repeat" items="{{status}}" as="option">
<paper-item value="{{option.value}}">{{option.name}}</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu>
</div>
</template>
<script>
class BaselinePolicyBasicInfo extends Polymer.Element {
static get is() { return 'baseline-policy-basic-info'; }
static get properties() {
return {
domain: {
type: Array,
value: []
},
status: {
type : Array,
value: [
{
name:"New",
value:"new"
},{
name:"Active",
value:"active"
}, {
name:"Inactive",
value:"inactive"
}
]
},
itemData: {
type: Object,
value: {},
observer: "_showData"
}
}
}
_showData(){
// TODO: fill in input fields if edit policy and info is available
}
}
customElements.define(BaselinePolicyBasicInfo.is, BaselinePolicyBasicInfo);
</script>
</dom-module>
不知道是什么导致了这个问题,我尝试了各种方法,例如缺少导入语句、重新运行 bower install,因为我认为我不小心删除了我的 prism-element 组件,并更改了一些导入语句的顺序。关于我应该做些什么来解决这个问题的任何想法。
解决方案
经过深思熟虑,我找到了一个解决方案,并认为我会在这里记录它,以防有人遇到同样的问题。
我有一个名为baseline-policies-tab.html 的父聚合物元素,其中baseline-policy-edit.html 是一个子元素。为了解决这个问题,我必须将baseline-policy-basic-info.html 的导入语句添加到baseline-policies-tab.html。
另外,我将baseline-policy-edit.html中的导入语句从
<link rel="import" href="baseline-policy-basic-info.html">
至
<link rel="import" href="../../src/baseline-policies/baseline-policy-basic-info.html">
我真的不知道为什么这会解决它,但如果有人遇到同样的问题,请尝试将导入语句添加到祖父元素(如果有的话)。
推荐阅读
- javascript - 通配符 Firebase 查询
- c# - AForge.Video / Materialskin 反复导致stackoverflow
- julia - 如何避免在 Julia 中使用 NLsolve 解决问题的过程中采用负幂函数基数?
- php - PHP websocket - 无法构建框架
- delphi - 如何使用 Delphi FMX 通讯簿组件获取手机号码
- intellij-idea - 在 Intellij 类图中编辑连接器
- python - 如何在 3d 图中绘制 2d 图像以计算对象深度作为 z 轴?
- android - 仅使用 8 GB RAM 构建 AOSP
- c - 为什么每次运行代码时第一个随机值都会增加?
- java - W/System.err: org.json.JSONException: org.json.JSONArray 类型为 0 的值 [] 无法转换为 JSONObject