How to upload .deb files using the jenkins pipeline and your credentials to the Nexus OSS

I I’m trying to use the Nexus repository to manage *.deb packages generated by jenkins, but when trying to upload these packages to nexus I’m getting a lot of errors, what is the best way to publish the packages in deb format that are in jenkins to a nexus repository apt, using the jenkins credential management mechanism to authenticate?

Using “Nexus Repository Manager Publisher” the apt repository does not appear, only maven repositories appear.

Tentei usar os seguintes scripts de pipeline:



withCredentials([usernamePassword(credentialsId: '3e4ea258-4b41-4379-a0fe-4462ed3e420a', passwordVariable: 'NEXUS_PASSWORD', usernameVariable: 'NEXUS_USERNAME')]) {
  sh '''
	for i in `/workspace/*.deb`
	do
		echo "Sending $i\r\n"
		curl -u \"$NEXUS_USERNAME:$NEXUS_PASSWORD\" -H "Content-Type: multipart/form-data" --data-binary \"@/$i\" "http://10.224.50.202:8081/repository/nerd4ever-labs/"
	done
  '''
}


withCredentials([usernamePassword(credentialsId: '3e4ea258-4b41-4379-a0fe-4462ed3e420a', passwordVariable: 'NEXUS_PASSWORD', usernameVariable: 'NEXUS_USERNAME')]) {
  sh '''
	for i in `/workspace/*.deb`
	do
		echo "Sending $i\r\n"
		curl -u $(NEXUS_USERNAME):$(NEXUS_PASSWORD) --upload-file $i "http://10.224.50.202:8081/repository/nerd4ever-labs/"
	done
  '''
}

With the above pipelines I get the error:

: Syntax error: newline unexpected

It’s my first contact with the Sonatype Nexus Repository Manager, I’m using an OSS 3.32.0-03 version.

I plan to use it for apt (debian), yum (centos) and poudriere (freebsd) and composer packages, but I’m struggling with the basics.

I’ve already set up the apt repository.