0

I am building a net project.

After my code getting compiled,all my DLLs are stored under (/obj/Release/PackageTmp) path.

Could any of you please suggest me how to copy folder and files under Jenkins Workspace(/obj/Release/PackageTmp) to Nexus repository or Any remote server using PS or Batch Command.

I am using Windows as a slave machine,I have used shell for my Linux machine:

curl --write-out "\nStatus: %{http_code}\n" --request POST --upload-file $JENKINS_HOME/workspace/${JOB_NAME}/$file -u ${NEXUS_LOGIN}:${NEXUS_PASSWORD} -v http://nexuslab/nexus/content/repositorie/$repository/$group/$artifact/$version/
Shahar Hamuzim Rajuan
  • 5,610
  • 9
  • 53
  • 91
Sangeetha
  • 125
  • 1
  • 5
  • 18
  • Possible duplicate of [Upload artifacts to Nexus, without Maven](http://stackoverflow.com/questions/4029532/upload-artifacts-to-nexus-without-maven). For upload of multiple files review the Sonatype support article referenced in the answers to the other question. – Ansgar Wiechers May 10 '16 at 08:43
  • @Ansgar Wiechers I wrote below script to execute this.But this is also not working.. curl --upload-file website.zip -u ${NEXUS_LOGIN}:${NEXUS_PASSWORD} -v http://nexus.sb.karmalab.net/nexus/content/repositories/egencia/com/egencia/midoffice/safenetws/1.0.0 – Sangeetha May 10 '16 at 10:35
  • Did you actually read the answers to that question? – Ansgar Wiechers May 13 '16 at 08:02

1 Answers1

0

Best way I can think of is uploading it with maven,

You can use maven command line or "invoke top-level maven step" as a Jenkins step.

When the mvn goal should be : mvn deploy

The only two things you need is having a pom and passing the arguments:

This is the pom you can use:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.hp.Maven</groupId>
    <artifactId>Maven-Nexus</artifactId>
    <packaging>pom</packaging>
    <version>1.0.0</version>

    <properties>
        <baseNexusURL>${baseNexusURL}</baseNexusURL>
        <targetRepositoryID>${repositoryId}</targetRepositoryID>
        <package.final.name>${project.artifactId}</package.final.name>
    </properties>

        <build> 
        <plugins>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>deploy-node-modules-artifact</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy-file</goal>
                        </goals>
                        <configuration>
                            <file>${file}</file>
                            <groupId>${groupId}</groupId>
                            <artifactId>${artifactId}</artifactId>
                            <version>${version}</version>
                            <packaging>${packaging}</packaging>
                            <generatePom>true</generatePom>
                            <repositoryId>${targetRepositoryID}</repositoryId>
                            <url>${baseNexusURL}/content/repositories/${targetRepositoryID}</url>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

enter image description here

Shahar Hamuzim Rajuan
  • 5,610
  • 9
  • 53
  • 91
  • I have added Pom file and executed job. Below is the error message.02:41:46 [INFO] Scanning for projects... 02:41:46 [ERROR] [ERROR] Some problems were encountered while processing the POMs: 02:41:46 [FATAL] Non-parseable POM d:\jenkins\workspace\bo-apollo-safenetws-build\pom.xml: Duplicated tag: 'properties' (position: START_TAG seen ...\r\n\t ... @12:18) @ line 12, column 18. – Sangeetha May 10 '16 at 09:46
  • this is how i defined properties..file=$WORKSPACE/bo-apollo-safenetws-build/bo-safenetws-rc.zip groupid=com.egencia.midoffice artifactid=bo-safenetws-rc version=1.0.0 packaging=zip repositoryid=egencia basenexusURL=http://nexuslab/nexus/content/repositorie – Sangeetha May 10 '16 at 09:48
  • After editing my properties latest error message is...03:00:02 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (deploy-node-modules-artifact) on project Maven-Nexus: The parameters 'file' for goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file are missing or invalid -> [Help 1] – Sangeetha May 10 '16 at 10:06
  • Latest Error---[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (deploy-node-modules-artifact) on project Maven-Nexus: The parameters 'file' for goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file are missing or invalid -> [Help 1] – Sangeetha May 10 '16 at 10:32
  • Yes I ran it with deploy as goal. New errror--The project (d:\jenkins\workspace\bo-apollo-safenetws-build\pom.xml) has 1 error 04:00:40 [ERROR] Non-parseable POM d:\jenkins\workspace\bo-apollo-safenetws-build\pom.xml: Duplicated tag: 'configuration' (position: START_TAG seen ...\r\n ... @24:20) @ line 24, column 20 -> [Help 2] – Sangeetha May 10 '16 at 11:02
  • Please copy the pom again, it's fixed now (There was a problem with pasting it) – Shahar Hamuzim Rajuan May 10 '16 at 11:09
  • New Error- The project [unknown-group-id]:[unknown-artifact-id]:[unknown-version] (d:\jenkins\workspace\bo-apollo-safenetws-build\pom.xml) has 4 errors.. Below are the properties-- file=safenetws groupId=com.egencia.midoffice artifactId=bo-safenetws-rc version=1.0.0 packaging=zip repositoryId=egencia baseNexusURL=http://nexuslab.alm/nexus – Sangeetha May 10 '16 at 11:19
  • Can I get your skype id to get this resolved personally – Sangeetha May 10 '16 at 11:20
  • Sorry, No skype account. Do you know how to start chat here? – Shahar Hamuzim Rajuan May 10 '16 at 12:02
  • No.. I am not aware how to chat in Stakoverflow – Sangeetha May 10 '16 at 12:16
  • If you have GMAIL we can chat there – Shahar Hamuzim Rajuan May 10 '16 at 12:36
  • yeah sure..kalyanbhave143@gmail.com is my ID – Sangeetha May 11 '16 at 05:41
  • After editing POM file. I got a new error.Where I could not see where exactly is the issue 23:59:40 [INFO] Installing d:\jenkins\workspace\bo-apollo-safenetws-build\pom.xml to C:\Users\v-kburramukku\.m2\repository\com\company\Maven\Maven-Nexus\1.0.0\Maven-Nexus-1.0.0.pom 23:59:40 [INFO] [deploy:deploy {execution: default-deploy}] 23:59:40 [INFO] Skipping artifact ******** 23:59:40 [INFO] [deploy:deploy-file {execution: deploy-node-modules-artifact}] 23:59:40 [INFO] ------------------------------------------------------------------------ 23:59:40 [ERROR] BUILD ERROR – Sangeetha May 11 '16 at 07:01
  • New error- Please suggest.. 01:57:00 [bo-apollo-safenetws-build] $ cmd.exe /C '"\var\lib\jenkins\tools\apache-maven\apache-maven-2.2.1\bin\mvn.bat -f pom.xml -DNEXUS_LOGIN=******** -DNEXUS_PASSWORD=******** -DCICD_GLOBAL_SERVICE_USER_KEY=******** -B deploy-file && exit %%ERRORLEVEL%%"' 01:57:01 [INFO] Scanning for projects... 01:57:01 [INFO] 01:57:01 [ERROR] FATAL ERROR 01:57:01 [INFO] 01:57:01 [INFO] Error building POM (may not be this project's POM). – Sangeetha May 12 '16 at 09:09
  • I'll login tomorrow and try to help you – Shahar Hamuzim Rajuan May 14 '16 at 18:16
  • Thanks @Shachar Hamuzim Rajuan – Sangeetha May 16 '16 at 08:49