How send files to custom dir in raw repository

I’m starting to use Nexus OSS, I’m trying to use the hosted type and raw format repository to distribute desktop applications developed in Qt. As the file structure is very simple, I thought I could use it for this.
I need to create a specific folder structure and I don’t know how to do that.

Basically I would need the directories (x86, x64) and inside each of them an executable (installer) and a folder called “updates”, inside this folder I would have an xml, another folder (with a namespace) and inside this folder ultima with namespace multiple files in 7z format.

Is it possible for me to do this?

|- x86
| – installer.exe
| – updates
| — my_namespace
| ---- file1.7z
| ---- file2.7z
| ---- fileN.7z
|- 64
| – installer.exe
| – updates
| — my_namespace
| ---- file1.7z
| ---- file2.7z
| ---- fileN.7z

@sobrito The structure you describe is completely possible, but Nexus Repository doesn’t explicitly store directories; it just stores the files you upload and associates them with whatever path you specify.

2 Likes

Thanks for your response!

This was one of the attempts I made to upload the file (it might sound ridiculous), but I’m having a hard time figuring out how to create this.

Using jenkins pipeline


stage('Publish') {
            steps {
                script{
                    def binaries = findFiles(glob: '*.exe')
                    binaries.each { item ->
                        sh "curl -v -u '${NEXUS_TOKEN}' -H 'Content-Type: multipart/form-data' --data-binary @${item} '${ENDPOINT}/${RELEASE_ARCH}/'"
                    }
                    
                    def metas = findFiles(glob: 'updates/*.xml')
                    metas.each { item ->
                        sh "curl -v -u '${NEXUS_TOKEN}' -H 'Content-Type: multipart/form-data' --data-binary @${item} '${ENDPOINT}/${RELEASE_ARCH}/updates/'"
                    }
                    
                    def packages = findFiles(glob: 'updates/updates/br.com.nerd4ever.kue/*.7z')
                    packages.each { item ->
                        sh "curl -v -u '${NEXUS_TOKEN}' -H 'Content-Type: multipart/form-data' --data-binary @${item} '${ENDPOINT}/${RELEASE_ARCH}/updates/br.com.nerd4ever.kue'"
                    }
                }
            }
        }

Don’t use form data, submit the content as the body.

1 Like

If you’re using curl, do as mentioned in the docs (Raw Repositories) and just use --upload-file [path-to-file]

1 Like

Thanks everyone, your response was very important, based on the post: “Nexus REST API Upload to Raw repository upload empty files”, I managed to find my error and fix my jenkins pipeline, it is now working correctly.

my pipeline that is working is in the example below, in case someone needs it in the future.

stage('Publish') {
            steps {
                script{
                    def binaries = findFiles(glob: '*.exe')
                    binaries.each { item ->
                        sh "curl -v -u '${NEXUS_TOKEN}' --upload-file '${item}' '${ENDPOINT}/${RELEASE_ARCH}/'"
                    }
                    
                    def metas = findFiles(glob: '**/Updates.xml')
                    metas.each { item ->
                        sh "curl -v -u '${NEXUS_TOKEN}' --upload-file '${item}' '${ENDPOINT}/${RELEASE_ARCH}/updates/'"
                    }
                    
                    def packages = findFiles(glob: 'updates/br.com.nerd4ever.kue/*.7z')
                    packages.each { item ->
                        sh "curl -v -u '${NEXUS_TOKEN}' --upload-file '${item}' '${ENDPOINT}/${RELEASE_ARCH}/updates/br.com.nerd4ever.kue/'"
                    }
                }
            }
        }

Congratulations!