Jenkins zipfile - jenkins

I want to do something very simple, in a folder I have a jar file and a folder called scripts that contains scripts. But I can get jenkins zip to do this.
zip dir: 'awsdeploy', exclude: '', glob: '', 'scripts/', zipFile: 'SQSToElasticProcessor.zip'
Arguments to "zip" must be explicitly named. # line 31, column 16.
zip dir: 'awsdeploy', exclude: '', glob: '*', 'scripts/*.*', zipFile: 'SQSToElasticProcessor.zip'

What I am trying to do is zip the following in the folder awsdeploy:
jarFile
scripts:
script1
script2
So I need to zip up the jar file and the subdirectory scripts

Related

How can i exclude package.json file itself when using electron-builder?

I'm using electron-builder to build my electron app.
I tried to exclude package.json file itself by the following config:
"build": {
"files": [
"dist/**/*",
"!node_modules/**/*",
"!package.json",
],
}
But it's not work!
when i extract app.asar file, I get:
dist // directory
package.json // file
How can i exclude package.json file itself?

Jenkins - "zip" Pipeline Utility - how to exclude Multiple files?

I want to build "zip" file and exclude multiple files: Jenkinsfile and test1.txt
I am able to exclude one specific file. This works:
stage ('First stage') {
steps {
zip zipFile: 'test.zip', archive: false, exclude: 'Jenkinsfile'
}
But how I can add to exclude test1.txt file as well?
I tried:
exclude: 'Jenkinsfile', 'test1.txt'
exclude: 'Jenkinsfile' 'test1.txt'
But it doesn't work!!!
Suggested solution on this link How to exclude Jenkinsfile and automation scripts in zip file pipeline utility plugin in Jenkins pipeline is NOT APPLICABLE!!!
Because exclude option is supported as explained on this link:
https://www.jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#zip-create-zip-file
Thank you!!!

Copy content of a directory to another Jenkins pipeline

I'm trying to copy the content of a directory into another directory on a Jenkins file.
My first attempt was using xcopy, but I'm getting an error ( Invalid number of parameters).
bat 'xcopy cashplus-backoffice/cashplus-backoffice-ui/build/web cashplus-backoffice/src/main/resources/static /e /h'
My second attempt was to using File Operation plugin as follows:
fileOperations([fileCopyOperation(
excludes: '',
flattenFiles: false,
includes: 'cashplus-backoffice/cashplus-backoffice-ui/build/web/**',
targetLocation: 'cashplus-backoffice/src/main/resources/static'
)])
The problem with this solution is that it copy the whole tree and the content of the source folder ( cashplus-backoffice/cashplus-backoffice-ui/build/web. I want just the content of the web folder ).
How can I achieve this?
You can use xcopy command and use \\ instead of \ for windows.
Example:
bat "xcopy /E /H C:\\Data\\myfiles C:\\Data\\Documents\\"

How to access environment variable from zip in Pipeline?

I have the following pipeline:
environment {
OUTPUT_FILE = 'OutputFile.zip'
}
stages {
stage('Build') {
steps {
// Build my app
zip archive: true, dir: 'zip', glob: '', zipFile: '${env.OUTPUT_FILE}'
}
}
}
I want to use the OUTPUT_FILE environment variable on the zip task, but it seems like the value is not resolved properly.
I have tried:
zip archive: true, dir: 'zip', glob: '', zipFile: '${OUTPUT_FILE}'
zip archive: true, dir: 'zip', glob: '', zipFile: '${env.OUTPUT_FILE}'
zip archive: true, dir: 'zip', glob: '', zipFile: '$OUTPUT_FILE'
None of them work.
You use incorrect syntax - in all your examples you use plain (and exact) string. However, in this case, you don't need to put env.OUTPUT_FILE inside any quotes, so the correct syntax is just:
zip archive: true, dir: 'zip', glob: '', zipFile: env.OUTPUT_FILE
or even
zip archive: true, dir: 'zip', glob: '', zipFile: OUTPUT_FILE
One thing worth mentioning. If you ever find yourself in a situation where you need to create a string using interpolation, then use double quotes. For instance, if you would like to echo the ZIP file name to console with some additional comment, then the following syntax would do the trick:
echo "The name of ZIP file is ${env.OUTPUT_FILE}"
Single quotes in Groovy are Java's String equivalent and they don't support variable interpolation.

scp all files within a DIR to remote using ant

I was trying to copy all the files within a directory from windows to unix within groovy method using following. But it does give an error saying No such file or directory
def antMove = new AntBuilder()
antMove.scp(trust: 'true',
file: "D:\\MyFolder\\input\\*",
todir: "username#[IP]:/tmp/rw_input/",
port: "22",
keyfile: Key,
passphrase: Passphrase,
verbose: "true")
I tried different option as well like *.* and * . But no luck
If I give just one file name here like test.txt its working fine
Thanks
Fileset can be added in the following way:
def ant = new AntBuilder()
ant.scp(
todir: "username#[IP]:/tmp/rw_input/",
verbose: true,
keyfile: "key",
trust: true
) {
fileset(dir: "D:\\MyFolder\\input\\") {
include(name: '*')
}
}

Resources