在本地构建和运行良好的 Polymer 项目无法在 Jenkins 上构建并出现 'Unable to load import' 错误?
Polymer project, that builds and runs fine locally, fails to build on Jenkins with 'Unable to load import' error?
我有一个使用 polymer-cli 构建的 Web 开发项目。在我的本地机器上,当我在项目文件夹中 运行 polymer build 时,我能够成功地构建项目。
但是,如果我尝试在 Jenkins 上构建项目,它会失败并出现 'Unable to load import' 错误。这是概述错误的控制台输出
[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
这是我的基线政策-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>
这是我的基线政策-基本-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>
不知道是什么导致了这个问题,我尝试了各种方法,例如
缺少导入语句,重新 运行ning bower install 因为我认为我不小心删除了我的 prism-element 组件,并更改了一些导入语句的顺序。关于我应该如何解决这个问题的任何想法。
经过深思熟虑,我找到了一个解决方案,并认为我会在此处记录下来,以防有人遇到同样的问题。
我有一个名为 baseline-policies-tab.html 的 parent 聚合物元素,其中 baseline-policy-edit.html 是一个 child 元素。为了解决这个问题,我不得不为 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">
我真的不知道为什么这会修复它,但如果有人遇到同样的问题,请尝试将导入语句添加到 grandparent 元素(如果有的话)。
我有一个使用 polymer-cli 构建的 Web 开发项目。在我的本地机器上,当我在项目文件夹中 运行 polymer build 时,我能够成功地构建项目。
但是,如果我尝试在 Jenkins 上构建项目,它会失败并出现 'Unable to load import' 错误。这是概述错误的控制台输出
[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
这是我的基线政策-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>
这是我的基线政策-基本-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>
不知道是什么导致了这个问题,我尝试了各种方法,例如 缺少导入语句,重新 运行ning bower install 因为我认为我不小心删除了我的 prism-element 组件,并更改了一些导入语句的顺序。关于我应该如何解决这个问题的任何想法。
经过深思熟虑,我找到了一个解决方案,并认为我会在此处记录下来,以防有人遇到同样的问题。
我有一个名为 baseline-policies-tab.html 的 parent 聚合物元素,其中 baseline-policy-edit.html 是一个 child 元素。为了解决这个问题,我不得不为 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">
我真的不知道为什么这会修复它,但如果有人遇到同样的问题,请尝试将导入语句添加到 grandparent 元素(如果有的话)。