I use this in my Jenkins pipeline:
def script = libraryResource 'tests/checks-test.sh'
file: 'script.sh', text: script
This will write a file script.sh in my workspace. Now I want that this file isn't in my workspace. (A bit like managed files which are in the /tmp/ folder of jenkins.
How can I force my pipeline to write the file in the /tmp folder and not in my workspace?
Related
I have a freestyle project in Jenkins to run Playwright functional tests. During the build execute shell step, I execute some Playwright functional tests. I have a setup locally that will give me the Playwright test report file playwright-report/index.html with this config:
// playwright.config.js
// #ts-check
/** #type {import('#playwright/test').PlaywrightTestConfig} */
const config = {
reporter: [['html', {
open: 'never',
host: '0.0.0.0',
port: 9223,
}]],
};
module.exports = config;
I am able to open and view this file locally but I am trying to figure out how to get this file on Jenkins Job. During the build running, I was able to verify that the file playwright-report/index.html does get created by printing out the directory withpwd, which returns root/run . So my root/run looks like this :
file-A.js
file-B.js
//...other folders
playwright-report
And when I cd playwright-report, I do see index.html file. However, all of the files, folders under root/run get archived after build, except for my playwright-report folder.
My post-build archive artifacts set up is '**/.' so I expect Jenkins to archive everything. My understanding is archive artifacts step copies the selected artifacts in the %JENKINS_HOME%/jons/MY_JOB/builds... on the master server. And it will only archive files under my WORKSPACE. Is this correct ?
So I am not sure why only my playwright-report folder is deleted after the build and it is not archived. I tried to create a folder playwright-dupe during the build and then copy playwright-report to playwright-dupe during the build, but neither playwright-dupe nor playwright-folder is archived.
So I think the directory root/run is different from the directory WORKSPACE ? I can't find any documentation about copying a folder from root/run and put it in WORKSPACE.
Can someone help me please ? My goal is to figure out how to access that index.html file Playwright report generates on Jenkins with each Jenkin jobs to build functional tests. Thank you
My environment variables:
JENKINS_HOME: var/lib/jenkins
pwd: /home/jenkins/agent
WORKSPACE: home/jenkins/agent/workspace/<project-name>
So to sum up I tried:
Create a duplicate folder and copy the result playwright-report over during build step
Change archive set up todist/**, home/jenkins/agent/workspace/<project-name>/**/*.*, **/playwright-dupe
I have a file in some folder on my computer that i want to add to the jenkins pipeline build folder before testing stage, without addind this file to the repository. is there a way to do that? this file is a config.yaml that contains a relevant version.
thanks
I would like to get a zip file with artifacts.
The archiveArtifacts directive in Jenkinsfile will save each artifact,
but when you download it you will get a zip files with original paths in it.
Is it possible to avoid original paths with a directive or am I obliged to
run a script that callects all artifacts in one single folder in the workspace and zip the folder then?
I am looking for the location of .sh file which is generated my jenkins job and can be found in console output. This .sh files starts with jenkins word.
I am using AWS instance for jenkins.
i was looking for /temp folder, but didn't get into /tmp folder.
sample of the .sh file name:
[first_gitbuild] $ /bin/sh -xe /tmp/jenkins8581903656897699418.sh
These files are deleted when job finishes.
I was able to get a copy of this .sh files with these steps:
Set a sleep in my script ( 5 mins )
Build the job
Go to /tmo folder and copy paste the script : /tmp/jenkins......sh
I have a groovy pipeline script checked into scm and loaded from jenkins.
The script is supposed to load a config file, fine-tuning its behavior. The config file is in the same directory as the script.
Can I somehow access this directory from the script? The working directory is set to the workspace, which is not where the script is located. Maybe I can somehow extract the directory of the script itself?