With Jenkins pipeline you are able to set any environment variable through Global Variable called - env.
Jelly template in it's turn gives you ability to access Jenkins API including hudson.model.AbstractBuild and hudson.model.AbstractProject objects.
Here are the snippets that I use:
Jenkinsfile:
node {
env.MYVAR = 'My variable'
emailext body: ${JELLY_SCRIPT, template="myTemplate"}, subject: 'MySubject', to: 'me'
}
Jelly template (myTemplate):
<?jelly escape-by-default='true'?>
<!DOCTYPE html [
<!ENTITY nbsp "&nbsp;">
]>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
<head>
<style>
body table, td, th, p, h1, h2 {
margin:0;
font:normal normal 100% Georgia, Serif;
background-color: #ffffff;
}
</style>
</head>
<body>
<j:set var="buildEnv" value="${build.getEnvironment(listener)}" />
<j:set var="myVar" value="${buildEnv.get('MYVAR')}" />
<table>
<tr>
<td>Variable</td>
<td>
<p>${myVar}</p>
</td>
</tr>
</table>
</div>
</body>
</j:jelly>
The problem is that I couldn't get access to my custom variable from the Jelly template.
I have tried a lot of possible ana impossible options (withEnv pipeline step, call several other methods from AbstractBuild class (getEnvironments, getBuildVariables), but nothing.
The only solution that I found is:
<j:set var="myvar" value="${it.getAction('org.jenkinsci.plugins.workflow.cps.EnvActionImpl').getOverriddenEnvironment()}"/>
<p>My var: ${myvar}</p>
Related
In the description of Svelte, Rich explained why it's important to use the import keyword for development, and I'm totally agree. He continues and says that in the production build it's using the traditional JavaScript packaging:
That's not to say we're abandoning bundlers altogether. It's still essential to optimise your app for production, and SvelteKit uses Rollup to make your apps as fast and lean as they possibly can be (which includes things like extracting styles into static .css files).
But when I'm building the famous example from npm init svelte#next with adapter set to node, I see that the output JavaScript still use the import keyword in the pages JS, and also use <link rel="modulepreload" ...> which is super modern for browsers, as mentioned. For example, here is the output HTML of the built for production index.html page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Home</title>
<link rel="modulepreload" href="/_app/start-331a94d4.js">
<link rel="modulepreload" href="/_app/chunks/vendor-a4e104ac.js">
<link rel="modulepreload" href="/_app/pages/__layout.svelte-ad0878a7.js">
<link rel="modulepreload" href="/_app/pages/index.svelte-49c07d7e.js">
<link rel="stylesheet" href="/_app/assets/start-61d1577b.css">
<link rel="stylesheet" href="/_app/assets/pages/__layout.svelte-a06e2686.css">
<link rel="stylesheet" href="/_app/assets/pages/index.svelte-1ae03b51.css">
<script type="module">
import { start } from "/_app/start-331a94d4.js";
start({
target: document.querySelector("#svelte"),
paths: {"base":"","assets":""},
session: {},
host: "127.0.0.1:3000",
route: true,
spa: false,
trailing_slash: "never",
hydrate: {
status: 200,
error: null,
nodes: [
import("/_app/pages/__layout.svelte-ad0878a7.js"),
import("/_app/pages/index.svelte-49c07d7e.js")
],
page: {
host: "127.0.0.1:3000", // TODO this is redundant
path: "/",
query: new URLSearchParams(""),
params: {}
}
}
});
</script>
</head>
<body>
<div id="svelte">
<header class="svelte-1twf6mk"><div class="corner svelte-1twf6mk"><img src="/_app/assets/svelte-logo-87df40b8.svg" alt="SvelteKit" class="svelte-1twf6mk"></div>
<nav class="svelte-1twf6mk"><svg viewBox="0 0 2 3" aria-hidden="true" class="svelte-1twf6mk"><path d="M0,0 L1,2 C1.5,3 1.5,3 2,3 L2,0 Z" class="svelte-1twf6mk"></path></svg>
<ul class="svelte-1twf6mk"><li class="svelte-1twf6mk active"><a sveltekit:prefetch href="/" class="svelte-1twf6mk">Home</a></li>
<li class="svelte-1twf6mk"><a sveltekit:prefetch href="/about" class="svelte-1twf6mk">About</a></li>
<li class="svelte-1twf6mk"><a sveltekit:prefetch href="/todos" class="svelte-1twf6mk">Todos</a></li></ul>
<svg viewBox="0 0 2 3" aria-hidden="true" class="svelte-1twf6mk"><path d="M0,0 L0,3 C0.5,3 0.5,3 1,2 L2,0 Z" class="svelte-1twf6mk"></path></svg></nav>
<div class="corner svelte-1twf6mk"></div>
</header>
<main class="svelte-1izrdc8">
<section class="svelte-mjk9ig"><h1 class="svelte-mjk9ig"><div class="welcome svelte-mjk9ig"><picture><source srcset="svelte-welcome.webp" type="image/webp">
<img src="svelte-welcome.png" alt="Welcome" class="svelte-mjk9ig"></picture></div>
to your new<br>SvelteKit app
</h1>
<h2>try editing <strong>src/routes/index.svelte</strong></h2>
<div class="counter svelte-ltn89m"><button aria-label="Decrease the counter by one" class="svelte-ltn89m"><svg aria-hidden="true" viewBox="0 0 1 1" class="svelte-ltn89m"><path d="M0,0.5 L1,0.5" class="svelte-ltn89m"></path></svg></button>
<div class="counter-viewport svelte-ltn89m"><div class="counter-digits svelte-ltn89m" style="transform: translate(0, 0%)"><strong style="top: -100%" aria-hidden="true" class="svelte-ltn89m">1</strong>
<strong class="svelte-ltn89m">0</strong></div></div>
<button aria-label="Increase the counter by one" class="svelte-ltn89m"><svg aria-hidden="true" viewBox="0 0 1 1" class="svelte-ltn89m"><path d="M0,0.5 L1,0.5 M0.5,0 L0.5,1" class="svelte-ltn89m"></path></svg></button>
</div>
</section></main>
<footer class="svelte-1izrdc8"><p>visit kit.svelte.dev to learn SvelteKit</p>
</footer>
</div>
</body>
</html>
How can I build SvelteKit with the node adapter, with the traditional JavaScript rollupjs output in the client code, e.g. without the import keyword?
It turns out that my question is a feature request for SvelteKit.
This will be done after releasing version 1.0 of SvelteKit.
Credit for dummdidumm for pointing me out for this while I opened a duplicated issue.
I am using grails 2.3.4
However when I start my application I get:
|Server running. Browse to http://localhost:8080/testApplication
....[/testApplication].[gsp] Servlet.service() for servlet [gsp] in context w
ith path [/testApplication] threw exception
java.lang.RuntimeException: It looks like you are missing some calls to the r:la
youtResources tag. After rendering your page the following have not been rendere
d: [defer]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewIns
tance(ReflectiveInterceptor.java:986)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstru
ctor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteN
oUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstru
ctor(CallSiteArray.java:57)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor
(AbstractCallSite.java:182)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor
(AbstractCallSite.java:190)
at org.grails.plugin.resource.DevModeSanityFilter.doFilter(DevModeSanity
Filter.groovy:54)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:210)
at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doF
ilterInternal(GrailsWebRequestFilter.java:69)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR
equestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:210)
at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilte
rInternal(HiddenHttpMethodFilter.java:67)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR
equestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterIntern
al(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR
equestFilter.java:107)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(D
elegatingFilterProxy.java:343)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(Delegat
ingFilterProxy.java:260)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:123)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:100)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp
11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoin
t.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:603)
at java.lang.Thread.run(Thread.java:722)
My index.gsp file looks like that:
<html ng-app>
<head>
<meta name="layout" content="main" />
<title>Title Page</title>
<!-- here we are loading angularjs -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.min.js"></script>
<!-- other way: <script src="" $ {resource(dir: 'js/lib', file: 'file.js')}"></script> -->
<!-- <r:require module="angular" />
<r:layoutResources />
-->
</head>
<body>
<div>
<div>
<label>Name:</label>
<input type="text" ng-model="yourName" placeholder="Enter a name here">
<hr>
<h1>Hello {{yourName}}!</h1>
</div>
</div>
</body>
</html>
As you can see the tag is commented out. So why do I get this and how to fix this long expeception?
I really appreciate your answer!
<r:layoutResources/> should appear twice in your page (or more usually in your layout GSP) - once just before </head> to render resources with the "head" disposition and again just before </body> to render the "defer" ones. It's the missing second occurrence that the error message is complaining about, the first isn't really "commented out" (it's inside an HTML comment so it will still be rendered, but its output will be commented out in the resulting HTML).
So you need to "uncomment" the first occurrence and also add the second one, or make sure that your page is using a layout that includes the <r:layoutResources/> tags at the right places.
I have installed:
compile ":jquery-ui:1.8.24"
compile ":jqgrid:3.8.0.1"
I got the next error:
| Error 2013-06-03 15:20:33,892 [http-bio-8080-exec-7] ERROR resource.ResourceMeta - While processing /plugins/jqgrid-3.8.0.1/css/jqgrid/ui.jqgrid.css, a resource was required but not found: /plugins/jqgrid-3.8.0.1/css/jqgrid/ellipsis-xbl.xml
I opened the file C:\Users\user\.grails\ivy-cache\org.grails.plugins\jqgrid\zips\jqgrid-3.8.0.1.zip. There is not any: css/jqgrid/ellipsis-xbl.xml
The latest version of JQGrid (4.5.2) has the file ellipsis-xbl.xml included. But I'm using the latest Grails plugin which uses that older version.
How could I tell Grails to look for ellipsis-xbl.xml in another location (let's say web-app/css/jqgrid-additions/ellipsis-xbl.xml).
I did a research on Google and it is what could be related:
taglib: <jqgrid:resources /> (according with the documentation, it
includes the required javascript and css for the plugin)
Add a configurationmapping in BuildConfig.groovy (I didn't find any
Grails documentation about that!)
I added to the GSP the next code to check if it looked at a different
location (and it check in the same location, at /plugins...):
<style>
.ui-jqgrid tr.jqgrow td {text-overflow:ellipsis; -moz-binding:url('ellipsis-xbl.xml#ellipsis');}
</style>
I end up by removing all css/js plugins except for jQuery (which is built-in). Just extract css/js files in /web-app directory. Then include them in /grails-app/conf/ApplicationResources.groovy like this:
modules = {
ui {
dependsOn 'jquery'
resource url: 'css/default.css'
resource url: 'css/print.css', attrs:[media:'print']
}
bootstrap {
dependsOn 'jquery'
resource url: 'css/bootstrap.css'
resource url: 'css/bootstrap-responsive.css'
resource url: 'js/bootstrap.js'
}
choice {
resource url: 'js/choice.js'
}
application {
dependsOn 'jquery,choice'
resource url: 'js/application.js'
}
}
Choice and application are application specific. Include here as an example. Then, call them in layout:
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><g:layoutTitle default="My Application" /></title>
<g:layoutHead />
<r:require modules="jquery,ui,bootstrap,choice,application" />
<r:layoutResources />
</head>
<body>
<div id="wrapper">
<div id="main" class="container-fluid">
<div class="row-fluid">
<div class="span12">
<g:layoutBody/>
</div>
</div>
</div>
</div>
<r:layoutResources />
</body>
</html>
This way, I can manage css/js library myself.
I am getting file name in action as null, uploaded from plupload plugin. how can i get the original file name. Please tell where is my mistake.
jsp
<%# page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%# taglib prefix="s" uri="/struts-tags"%>
<%# taglib prefix="sj" uri="/struts-jquery-tags"%>
<html>
<head>
<title>test</title>
<sj:head compressed="false"/>
<link rel="stylesheet" type="text/css" href="plup/jquery.plupload.queue/css/jquery.plupload.queue.css" type="text/css" media="screen" />
<script type="text/javascript" src="plup/plupload.full.min.js"></script>
<script type="text/javascript" src="plup/jquery.plupload.queue/jquery.plupload.queue.js"></script>
<script type="text/javascript">
/* Convert divs to queue widgets when the DOM is ready */
$(function(){
function plupload(){
$("#uploader").pluploadQueue({
// General settings
runtimes : 'html5,gears,browserplus,silverlight,flash,html4',
url : 'uploads',
max_file_size : '10mb',
unique_names : true,
chunk_size: '2mb',
// Specify what files to browse for
filters : [
{title: "Image files", extensions: "jpg,gif,png"},
{title: "Zip files", extensions: "zip"}
],
resize: {width: 320, height: 240, quality: 90},
// Flash settings
flash_swf_url : 'plup/Moxie.swf',
// Silverlight settings
silverlight_xap_url : 'plup/Moxie.xap',
multipart_params: {'user': 'admin', 'time': '2012-06-12'}
});
}
plupload();
$('#clear').click(function(){
plupload();
});
});
</script>
</head>
<body>
<div>
<div style="width: 750px; margin: 0px auto">
<form id="formId" action="submit.action" method="post">
<div id="uploader">
<p>Flash, Silverlight, Gears, BrowserPlus,HTML5 .</p>
</div>
<input type="button" value="Clear" id="clear"/>
</form>
</div>
</div>
</body>
</html>
Action
#Action(value="plupUploaduploads")
public String upload() throws Exception {
isMultipart = ServletFileUpload.isMultipartContent(getReq());
System.out.println(getReq().getParameter("value"));
ServletContext servletContext = getReq().getServletContext();
String filePath = servletContext.getRealPath("/");
System.out.println(filePath);
System.out.println(this.file);
System.out.println(this.fileName);
System.out.println(this.contentType);
File theFile = new File("c:\\",this.getFileName());
FileUtils.copyFile(file,theFile);
return SUCCESS;
}
//getters and setters
i can see this on console according to print statements given.
o_17oq47949abc11n51pg11rnah06a.jpg
E:\Documents and Settings\Pluto\My Documents\NetBeansProjects\ShareApp\build\web\
c:\temp\upload__408094b5_13e30976641__7fea_00000003.tmp
null
null
is it the problem in my struts config? I am using annotations hence dont have struts.xml file. Or the problem is in plupload sending the file name, because when i retrived the name parameter i am getting some different name "o_17oq47949abc11n51pg11rnah06a.jpg" which is not the actual name. If so how can i get the original name?
Thanks and regards
I still don't understand why you are using all this plugins to perform an operation that simple. Do you need AJAX upload ? If not, you can simply use <s:file /> to upload one or more files to Action, with automatic filesize check, filename and contenttype detection, by simply declaring three variables with the same prefix into your Action:
Action code:
private File fileUpload;
private String fileUploadContentType;
private String fileUploadFileName;
/* getters and setters */
JSP code:
<s:file name="fileUpload" />
Then you can perform a client-side (HTML5, with javascript) filesize check, a server-side filesize check, and set a server-side overall multipart request size (in Struts.xml, that you should have even when using Annotations).
You can read the details here: struts2 s:form element trims the s:url parameter in the action attribute
As a final suggestion: make something simple that works, then start customizing / extending it.
Solution:
Add fileupload interceoptor in struts.xml (< interceptor-ref name="fileUpload" />)
Add the following properties in the action class.
private String[] fileFileName;
private String[] fileContentType;
private File[] file;
It is solved now. I set unique_names : false in plupload options. The content type and filename are null in struts action. I retrieved file name using getParameter("name");.
I am Doing an Export to Excel with my Ruby on Ralis application.I have not used any gem or Plugin (since our requirement was something different, we couldn't use them). We used the inbuilt "format.xls" support that comes with Ruby on Rails.
The problem is that, when we get our Excel, Save as Type appears on the webpage. I want to change this to Microsoft Office Excel Workbook (*xls). How to do it?
Below is my controller action code and the respective view with which we get the excel.
Get_excel methods in controller
def get_excel
format.xls do
headers['Content-Type'] = "application/vnd.ms-excel"
headers["Content-disposition"] = 'inline; filename="myexcel.xls"'
headers['Cache-Control'] = ''
end
end
VIEW (get_excel.xls.erb)
<html xmlns:o="urn:schemas-microsoft-com:office:office
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40"
xmlns:ss = "urn:schemas-microsoft-com:office:spreadsheet" />
<head>
<meta http-equiv=Content-Type content="text/html; charset=UTF-8"/>
<meta name=ProgId content=Excel.Sheet/>
<meta name=Generator content="Microsoft Excel 11"/>
<style type="text/css">
#page {
mso-header-data : '&R CONFIDENTIAL';
margin: 0.75in 0.20in 0.5in 0.20in;
mso-header-margin: 0.25in;
mso-footer-margin:0.25in;
mso-page-orientation: landscape;
}
table{
page-break-inside: avoid;
}
td{
white-space:nowrap;
}
</style>
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets
<x:ExcelWorksheet>
<x:Name>Gantt Detail</x:Name>
<x:WorksheetOptions>
<x:DefaultRowHeight>319</x:DefaultRowHeight>
<x:Print>
<x:FitHeight>15</x:FitHeight>
<x:ValidPrinterInfo/>
<x:Scale>74</x:Scale>
<x:HorizontalResolution>600</x:HorizontalResolution>
<x:VerticalResolution>600</x:VerticalResolution>
</x:Print>
<x:Selected/>
<x:FrozenNoSplit/>
<x:SplitHorizontal>5</x:SplitHorizontal>
<x:TopRowBottomPane>5</x:TopRowBottomPane>
<x:ActivePane>2</x:ActivePane>
<x:Panes>
<x:Pane>
<x:Number>3</x:Number>
</x:Pane>
<x:Pane>
<x:Number>2</x:Number>
</x:Pane>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
<x:WindowHeight>8580</x:WindowHeight>
<x:WindowWidth>12120</x:WindowWidth>
<x:WindowTopX>120</x:WindowTopX>
<x:WindowTopY>45</x:WindowTopY>
<x:ProtectStructure>False</x:ProtectStructure>
<x:ProtectWindows>False</x:ProtectWindows>
</x:ExcelWorkbook>
<x:ExcelName>
<x:Name>Print_Titles</x:Name>
<x:SheetIndex>1</x:SheetIndex>
<x:Formula>='Gantt Detail'!$3:$5</x:Formula>
</x:ExcelName>
</xml><![endif]-->
</head>
<body>
<table>
<tr>some code</tr>
<tr>some code</tr>
<tr>some code</tr>
<tr>some code</tr>
<tr>some code</tr>
</table>
</body>
In config/initializers/mime_types.rb
Mime::Type.register "application/vnd.ms-excel", :xls
Then you shouldn't need to set headers directly in the method.
I'm not sure if this will stop you from being prompted, but it's how I serve HTML tables as xls and nobody ever has a problem opening them.
I also don't set a filename, as the method name will name it (get_excel.xls in your case).
I also don't set all the xml and xmlns stuff either. It just works.