在本地构建并运行良好的Polymer项目,无法在Jenkins上构建并显示“无法加载导入”错误?

时间:2018-08-02 20:25:24

标签: jenkins polymer polymer-2.x

我有一个使用Polymer-cli构建的Web开发项目。在本地计算机上,当我在项目文件夹中运行Polymer build时,便能够成功构建项目。

但是,如果我尝试在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安装,因为我认为我不小心删除了棱镜元素组件,并更改了某些导入语句的顺序。有关如何解决此问题的任何想法。

1 个答案:

答案 0 :(得分:0)

经过深思熟虑,我找到了一个解决方案,并认为如果有人遇到同一问题,我会在这里进行记录。

我有一个称为“ baseline-policies-tab.html”的父聚合物元素,其中“ baseline-policy-edit.html”是一个子元素。要解决此问题,我必须将基线基准-cycy-basic-info.html的导入语句添加到基线基准-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">

我真的不知道为什么要解决此问题,但是如果有人遇到相同的问题,请尝试将导入语句添加到祖父母元素中。