I'm attaching a template in email using Jenkins. I've created a folder name email-templates under .jenkins and there I've placed my template with the name build-report.groovy.
Good thing is i can attach this template in email ext using ${SCRIPT, template="build-report.groovy"} and i can see the expected data in email.
But if i use ${SCRIPT, template="groovy-html.template"} i can also see the same template data with colors and styles.
I didn't have any template file with name groovy-html.template then from where Jenkins picked ?
It's a part of email-ext Jenkins plugin and it's located inside of corresponding jar file.
You can see it in the source code:
https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/resources/hudson/plugins/emailext/templates/groovy-html.template
Related
I am using a file parameter in my Jenkins Job.
E.g. src/main/resources/file1.txt;
Now I have three files in the same directory (src/main/resources) : file1.txt, file2.txt, file3.txt
If I enter the path of file param as : src/main/resources/file1.txt
Then the uploaded file will be replacing the file1.txt file in my workspace.
Problem Statement :
I want the file parameter to be dynamic in nature so that I can upload file1/2/3 and it should replace the corresponding file in my workspace in directory(src/main/resources/).
Need suggestion if this can be achieved in Jenkins.
This is possible. You need to use 'Active Choice Reactive Reference Plugin'.
https://plugins.jenkins.io/uno-choice/
I'm using Pipeline Plugin under Jenkins
My job is basically using a file called "jenkinsFile" to get the divers steps to run.
-> My purpose is how to let the job use a different file name :
examples:
myJenkinsFile
build_JenkinsFile
deploy_JenkinsFile
buildSteps
...
Since it seems that "JenkinsFile" is a conventional format ,
is there any ways to change it if it's not verry clean ??
Suggestions ??
On the project section of the configuration page you just have to click Add > Pipeline Jenkins and then you can choose the custom name that jenkins will look for the pipeline.
If you want also a better level of customization you can also use Remote File Plugin, which allows you to put your pipeline in a repository and make it work with multiple repositories/branch (and of course you can still customize the name of the file)
I have a project that should at the end send an email with a file.
During the build i have the following env.variable:
$TARGET_INDEX=/.../.../.../index.html
In the "Editable Email Notification" i have configured:
Content Type - HTML
Default Content - ${FILE,path="${TARGET_INDEX}"}
But at the end of the build I got the below trace:
+ TARGET_INDEX=/.../.../.../index.html
[EnvInject] - Injecting environment variables from a build step.
[EnvInject] - Injecting as environment variables the properties file path 'tmp_default.properties'
[EnvInject] - Variables injected successfully.
No emails were triggered.
I can't understand why no email was triggered!?
Any clue? Do you have another approach to send email with HTML as content?
Editable Email Notification has an Attachment section and it use Ant script.when you require an email trigger at the end of your build including file as an attachment then it will help full for you to know Ant script work mainly on relative addressing rather than absolute addressing. so content in attachment pattern should be some thing like this
**/foldername/*.txt
(anyextension)
Note:make sure the floder exists in your job workspace and your index.html is placed in that folder.
Hope this helps to some extent
You need to check the Triggers section, which will be hidden by default.
You need to click the "Advanced Settings" button to show this section.
Can I display the contents of another file in my jelly script output?
If the file is included in the workspace of the job, declare your variable such as:
<j:set var="fileContent" value="${build.getWorkspace().child("results.html")}"/>
And call it this way:
${fileContent}
Yes, you can use the ${FILE, path} token to include the contents of a file (path is relative to your workspace directory).
This info is taken from the Content Token Reference in the email-ext part of your job configuration. Click the question mark on the right to get the full list of tokens.
Look at util:loadText which is a "tag which loads text from a file or URI into a Jelly variable."
<u:loadText var="contents" file="${filename}"/>
${contents}
Haven't used it inside of Jenkins before... let us know if it works.
I'm trying to insert the content of a file inside a job description. My build generates a file and I can find it easily with the following URL: http:/[my-domain]job/[my-job]/lastBuild/artifact/[my-file]. In my case, this is a text file and I would like to display it in the job description. I can easily insert a link to this file with HTML but how can I insert the content of this file ?
What is your Jenkins running on? Windows or Linux?
The Project Description Setter plugin is indeed the way to go, but you need to display the content of your file in the build log first, before the plugin will pick it up.
Like Christopher said, you don't need a job URL to access the file that you have in your workspace.
For Linux, put the following into your shell execute step:
echo -n "[DESC] " && cat myfile
For Windows, use this:
echo|set /p="[DESC] " & type myfile
This will print the content of file and prefix it with "[DESC]". We need this prefix (it can be anything you want) to identify this line to the Description Setter plugin
In the job configuration, under Set build description, type:
\[DESC\] (.*)
One note: only the first line of the file will be printed in description
The Project Description Setter plugin can do this.