Jenkins file operations zip: zip the contents of a folder without including the folder itself on Microsoft Windows - windows

The current zipped result looks like this:
zipped_dir -> folder -> root_folder -> some files
I would like it to function like this command:
cd folder; zip -r ../zipped_dir.zip *
desired result:
zipped_dir -> root_folder -> some files
Jenkins version 2.72, File Operations plugin 1.6.
Source Code Management: Git
branches to build: **/tags/production/**
build triggers: Poll SCM
File operations
file copy :
include pattern: application/**
Exclude File pattern: <blank>
Target Location: ${GIT_BRANCH}
file zip:
Folder Path: ${GIT_BRANCH}

burnettk had the answer to the question.
post answer, jenkins was installed on windows and required MinGW for the zip command.
http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/
Make sure you have MinGW (usually C:\MinGW\msys\1.0\bin) in the Path environment variable.
install these packages.
mingw-get install msys-unzip msys-wget msys-zip
It seems restarting the jenkins service made it recognize the path addition.
jenkins could then use the zip command.

Related

AzureDevops Release - Command Shell "do not have permissions"

I've created a release on Azuredevops with a Command Line Task.
The script is really simple :
Unzip the artifcats and move it to another folder.
But owner's folder is not the same between the Agent Deployment and the repository.
I add chmod 777, it's works, but is not the best answer.
Do you have another solution ?
AzureDevops Release - Command Shell “do not have permissions”
Indeed, to unzip the artifcats and move it to another folder, we could use Extract Files task to complete this:
Extract Files task
Use this task in a build or release pipeline to extract files from
archives to a target folder using match patterns. A range of standard
archive formats is supported, including .zip, .jar, .war, .ear, .tar,
.7z, and more.
BTW, there is an extension to Unzip a directories Zip and unzip directory build task
Hope this helps.

Where m2 file is stored when installing apache maven on a unix box

I downloaded maven gz file, unzipped same, but i dont know where the m2 is stored. I imagine im missing a step but i cant see what one?
Is there aninstall script etc?
[root#atddpvm5 apache-maven-3.5.4]# cd /var/tmp/apache-maven-3.5.4/
[root#atddpvm5 apache-maven-3.5.4]# ls
apache-maven DEPENDENCIES doap_Maven.rdf LICENSE maven-builder-
support maven-core maven-model maven-plugin-api
maven-resolver-provider maven-settings-builder NOTICE README.md
CONTRIBUTING.md deploySite.sh Jenkinsfile maven-artifact maven-compat
maven-embedder maven-model-builder maven-repository-metadata maven-
settings maven-slf4j-provider pom.xml src
By default the .m2 folder is stored in the home folder of the user. In this case since you are using root, the path is most likely /root/.m2. You also have to use the -a switch with ls to see that folder, since it's a hidden folder (it starts with a .). Note that the folder will only be created on the first usage of Maven, i.e. when you call a maven command on a maven project, like mvn clean install.
Additionally it looks like you have downloaded the source distribution of Maven, which only makes sense if you want to work on Maven itself. You might want to download the binary distribution, if you just want to use it.

Unzip using VSTS build

I am unable to unzip the file using VSTS git.
I have tried using unzip, extract file, unzip file but none shows the unzipped file after the build is successfully run
Refer to these steps below to push unzipped files to git repository:
Go to Admin page of that team project (https://{account}.visualstudio.com/{project name}/_admin/_versioncontrol?repoGroup=true&_a=security)
Select corresponding repository
Select Project Collection Build Service (xxx) user and change Contribute permission to Allow
Edit build definition, select the Phase and check Allow scripts to access OAuth token option
Upzip zip files to a directory task: Zip files to unzip: $(System.DefaultWorkingDirectory)\cicdadf.zip; Upzip to path:$(System.DefaultWorkingDirectory)
Command line task: Tool: git; Arguments: config --global user.email you#example.com. Working folder: $(System.DefaultWorkingDirectory)
Command line task: Tool: git; Aeguments: config --global user.name "Your Name"; Working folder: $(System.DefaultWorkingDirectory)
Command line task: Tool: git; Arguments: add cicdadf/**; Working folder: $(System.DefaultWorkingDirectory)
Command line task: Tool: git; Aeguments: commit -m "add unzipped files"; Working folder: $(System.DefaultWorkingDirectory)
Command line task: Tool: git; Aeguments: push https://test:$(System.AccessToken)#{account}.visualstudio.com/{team project}/_git/{respository} HEAD:master; Working folder: $(System.DefaultWorkingDirectory)
Make sure that you have added path variables correctly. The default relative path is the folder where all sources for the build definition are synced. You can go thought other directories/files on the build agent by using full paths or variables in the path. All input boxes for paths do accept variables. For example the source directory is: $(Agent.BuildDirectory)\s. Or use your own variables for the build/release pipeline in the paths.
Reference:https://marketplace.visualstudio.com/items?itemName=petergroenewegen.PeterGroenewegen-Xpirit-Vsts-Build-Zip

target folder is getting created while building pom.xml - maven

I want to copy the files from Unix/linux server to SVN repository
Do svn export work?
If yes, please help with command how exactly I have to write the command.
Suppose if files are unix server on path : /appl/project/dev
And svn repository is : svn://scm.it.abc.com:XXXX/REL100
And i want to copy all files from unix path to SVN repository.

How to use gradle zip in local system without downloading when using gradle-wrapper

I'm trying to build a gradle project with gradle-wrapper (gradlew).
When I build with ./gradlew build, it outputs text
Downloading http://services.gradle.org/distributions/gradle-1.11-bin.zip
And I already got gradle-1.11-bin.zip downloaded separately and I don't want to be downloading it again when I build.
So, where shall I put gradle-1.11-bin.zip in my project or system so that I don't have to download again?
gradle/wrapper/gradle-wrapper.properties is as following.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-bin.zip
And I've tried copying gradle-1.11-bin.zip into gradle/wrapper/dists which didn't solve the problem.
From gradle-wrapper documentation, I found in section 61.1. Configuration
If you don't want any download to happen when your project is build
via gradlew, simply add the Gradle distribution zip to your version
control at the location specified by your wrapper configuration. A
relative URL is supported - you can specify a distribution file
relative to the location of gradle-wrapper.properties file.
So, I changed distributionUrl property in gradle/wrapper/gradle-wrapper.properties to
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=gradle-1.11-bin.zip
Then, I made a copy of gradle-1.11-bin.zip in gradle/wrapper/.
Then, ./gradlew build downloaded local copy of zip and built the project.
Here's a real-world example:
mkdir -p $HOME/dev
cd $HOME/dev
git clone https://github.com/oss-review-toolkit/ort
cd ort/gradle/wrapper
wget https://services.gradle.org/distributions/gradle-7.5.1-bin.zip
sed -i 's/distributionUrl=.*/distributionUrl=gradle-7.5.1-bin.zip/' gradle-wrapper.properties
cd ../..
./gradlew installDist
Modifty the gradle/gradle-wrapper.properties
Windows:
distributionUrl=file\:/d:/gradle-2.2.1-all.zip
linux:
distributionUrl=file\:/tmp/gradle-2.2.1-all.zip
Just drag downloaded gradle file in your browser address bar and then copy address from address bar and change gradle/wrapper/gradle-wrapper.properties as following:
distributionUrl=ADDRESS THAT COPY FROM YOUR BROWSER
example:
distributionUrl=file:///E:/gradle/gradle-4.1-all.zip
or you can copy gradle.zip file to wrapper folder then use relative path:
distributionUrl=gradle.zip
This is what I did to avoid editing all gradle wrapper for current and future projects.
Locate your gradle-wrapper.properties in your project folder (eg. ./gradle/wrapper/gradle-wrapper.properties)
open the file with a text editor like Sublime Text to locate the distributionUrl line (eg. distributionUrl=http\://services.gradle.org/distributions/gradle-2.10-bin.zip
The gradle binary archive needed is gradle-2.10-bin.zip. Another version is gradle-2.10-all.zip that includes everything including source code and documentation.
Please note each project ships with different versions of gradle distributions and you can change the version to the one you have (gradle-x.xx-XXX.zip) that include the binary. (eg. gradle-2.11-bin.zip | gradle-2.11-all.zip ).
Execute gradlew.bat on window or gradle on linux to start the wrapper to build the project.
It will begin downloading the gradle-2.10-bin.zip to the .gradle\wrapper\dists in your home directory (eg.C:\Users\Sojimaxi\.gradle\wrapper\dists\gradle-2.10-bin). This download happens just once for each specified gradle version.
If you already downloaded the archive before you can terminate the download using Ctrl+C
Go into the gradle download location C:\Users\Sojimaxi\.gradle\wrapper\dists\gradle-2.10-all\78v82fsf226usgvgh7q2ptcvif copy your own copy of gradle-2.10-bin.zip into that directory then delete the gradle-2.10-all.zip.part in that directory.
That's all. Go back to your project directory to execute gradlew.bat and it will use your local copy instead of downloading a new one.
This solution didn't work for me but help me to get the right way so if you want install gradle offline follow these steps:
1- at your project under gradle directory open this file (gradle-wrapper.properties)
2- at last line you will find the gradle version, download that version or copy the file from another pc
distributionUrl=http\://services.gradle.org/distributions/gradle-3.3-bin.zip
Download Link will be like this: http://services.gradle.org/distributions/gradle-3.3-bin.zip
3- open this location
C:\Users\userName.gradle\wrapper\dists\gradle-3.3-all
and ensure that is only one folder (the name doesn’t matter it different at devices) if there any other folders delete all of them and press gradle sync on android studio which will generate another folder automatic with a random name.
4- open that folder and ensure that has only the last two files in the screenshot.
5- move the zip file that you downloaded into that folder
6- press sync gradle on android studio again suppose that gradle will work fine.
I found another easiest way to do this just started my XAMPP server and then made a folder gradle inside htdocs. I added the zipped file gradle-4.4-all.zip inside that folder. Changed the distribution url to distributionUrl=http\://localhost/gradle/gradle-4.4-all.zip
I restarted android and the syncing completed without any issue.
copy your path wher you put the file gradle-5.0-rc-5-bin.zip
example:
path C:/My doc/tools
if you have some spaces in your path change it with %20
file:///C:/My%20doc/tools/gradle-5.0-rc-5-bin.zip
and execute the command:
$ gradlew wrapper --gradle-version 5.0-rc-5
I download to
C:\data\Setup\Development\Gradle 2.11\gradle-2.11-all.zip
inside Eclipse, I declare:
Then I create new Gradle project (with wrapper) very fast, no need download. (Easy more than this solution)
create local server to mock https download(maybe a little complex),but it work
1. install tomcat then unzip and exec E:\apache-tomcat-8.5.4\bin\startup.bat
2.put gradle-2.14.1-all.zip to E:\apache-tomcat-8.5.4\webapps\ROOT\distributions
3.change url like this distributionUrl=http\://localhost:8080/distributions/gradle-2.14.1-all.zip
now run as usual
// Do not use android 8 as it will keep downloading grade distribution use grade 7
ionic cordova platform add android#8.0.0
// This will run
ionic cordova platform add android#~7.1.1 --save
Then run below and this time it should get success( Worked for me)
ionic cordova build android

Resources