Curl command to push a war file to url in github actions - url

So I'm having in issue where I want this maven installed war file to be named artifactId##version.war in a curl commands url; in the curl command I tried putting in \ and %23 but both instances I get this message The Path is not formatted correctly - must begin with '/repositories//...' and when its just the name artifactId##version when it pushes or uploads it to the website I want it only names it artifactId and leaves out the rest, the problem isn't in getting the artifactID name or version number or the maven install it's in the curl command portion of the code and the reason why I have two FILE_TO_UPLOAD is because of one is the file name installed and another is whats gonna be the name uploaded and like I said if I just put ## it'll just upload the artifactId
run:|
mvn install
#CODE WHERE THE PROBLEM IS
FILE_TO_UPLOAD="ARTIFACTID\#\#VERSION.war"
FILE_TO_UPLOAD2="ARTIFACTID##VERSION.war"
echo ${FILE_TO_UPLOAD} #for testing
TARGET_URL=https://example.com/PATH/${FILE_TO_UPLOAD}
curl -u 'username:password' --upload-file ${FILE_TO_UPLOAD2} ${TARGET_URL}
#CODE WHERE THE PROBLEM IS

Related

How to delete a directory from nexus using curl command

I'm currently using this command to delete a specific file from a directory
and it works as expected
curl -s -u user_name:password --request DELETE https://host_name/repository/Folder/artifact.py
I would like to delete the Folder Directory using this curl command but this isn't working : (
curl -s -u user_name:password --request DELETE https://host_name/repository/Folder
please help with the command to delete the directory using the curl command.
Thanks in advance : )
This is not possible in Nexus 3. You can follow this enhancement request for the feature on the project's Jira, https://issues.sonatype.org/browse/NEXUS-11881.
The only solution seems to either delete the directory (subtree) manually using the Web UI, as implemented in https://issues.sonatype.org/browse/NEXUS-14682.
Or write a script that will search for all files in the subtree and delete them one by one (after which the empty directories will also disappear), for example something like https://gist.github.com/kamal2222ahmed/c3d65dfac3f2bc26183e7f5e4caa51cd

Jenkins cannot find g++

I am learning all of these new technologies. I have a home server for private development with latest version of centos 7.6 (minimal installation). I am trying to keep the server as light as possible.
I have installed jenkins (v2.164.2) and it is up and running correctly. I have created a new Freestyle project to compile a g++ project hosted on another own gogs server. I have defined gogs url and credentials and then added the following in the execute shell command:
which g++; make clean; make;
When I press the "Build Now" button, it fails with the following message:
which: no g++ in (/sbin:/usr/sbin:/bin:/usr/bin)
Cloning the repository, etc seems to be working fine.
I have NOT installed the default g++ version but instead I have installed the one that comes with devtools-7 (g++ v7.3.1). I have created a new file under /etc/profile.d/devtools.sh with the following text:
!#/bin/bash
source scl_source enable devtoolset-7
If I login into a bash shell in the server and then run which g++, I get the expected output.
Finally, the question: why jenkins is not picking this up? As far as I know, adding that file under /etc/profile.d ensures that everyone will be able to access g++.
Thanks very much in advance for any help.
I have managed to fix it at the end. I leave the question just in case someone else runs into the same problem. I only had to add the following line as first line in the "execute shell" command field:
#!/bin/bash -l
make clean; make;
That #!/bin/bash -l did the trick. (Please mind the -l).
Found it here: What shell does Jenkins use?

How to use swagger code-generator

I am working on creating the rest client and I will be calling an API which gives this big json output .I want to know how to create the Pojo classes automatically by inputting this json to swagger code gen and let it create my pojo classes for me which will save manual time . Here is what I have tried
To generate a PHP client for http://petstore.swagger.io/v2/swagger.json, please run the following
git clone https://github.com/swagger-api/swagger-codegen
cd swagger-codegen
mvn clean package
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l php \
-o /var/tmp/php_api_client
(if you're on Windows, replace the last command with java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client)
I could not get pass the mvn clean package and it is giving the error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project swagger-codegen: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process
[ERROR] java.lang.NoClassDefFoundError: io/swagger/models/properties/Property
Anyone have successfully used this swagger ? or even if you can suggest any other framework which can do this functionality would be of great help . Thanks in advance ..,
I seen the following link
Update code generated by Swagger code-gen
and able to run the application .. Can anyone explain if I can use this to get the pojo object created for the json input?
Your problem is not swagger itself. Your problem comes from maven and it says that it can't find a certain class. I downloaded the repo and it compiles on my machine with mvn validate package. Make sure you have .m2\repository\io\swagger\swagger-models... in your standard maven cache directory. Thats the dependency, which has the Property class.
Actually maven should download it right before compiling. Check the maven output for connection errors or unreachable downloads etc.

Travis-CI: Where do I find the path to the file I downloaded, and find out "where I am"?

I would like to download data into the travis environment via a public URL:
before_install:
- curl -OL http://publicwebsite.org/data/subdirectory2
My problem is that I don't know whether the data downloaded successfully.
My question is, how do I now find this data? I have assumed that it would be found at /home/travis/build/subdirectory2, but this isn't true.
Commands such as pwd and ls do not show me the files downloaded in the build, or where I am.
$PWD is $TRAVIS_BUILD_DIR when the execution gets to before_install. https://docs.travis-ci.com/user/environment-variables#Default-Environment-Variables
If you are unsure of where it is, though, you can pass -o /path/to/file to curl.

Using createItem remote API with CloudBees folder plugin to create nested jobs or subdirectories

I am attempting to create nested directories and jobs mirroring the structure of my SVN repository using the CloudBees Folder plugin and Jenkins remote API.
For a subdirectory (assume I've copied the config.xml to my CWD):
wget --no-proxy --auth-no-challenge --http-user=username --ask-password --header="Content-Type: application/xml" --post-file="dconfig.xml" 'http://ci.mycompany.com/jenkins/createItem?name=foo'
works. When the command completes, I have a newly created "foo" folder in the top level of my dashboard. However when I try:
wget --no-proxy --auth-no-challenge --http-user=username --ask-password --header="Content-Type: application/xml" --post-file="dconfig.xml" 'http://ci.mycompany.com/jenkins/createItem?name=foo/bar'
I get a "ERROR 400: Bad Request". I've also tried substituting "name=/foo/bar", "name=%2Ffoo%2Fbar", and "name=foo%2Fbar", all with the same results.
Likewise, I get a similar result when using the createItem/from/mode/name API to copy internal folders:
wget --no-proxy --auth-no-challenge --http-user=username --ask-password --header="Content-Type: application/xml" --post-file="dconfig.xml" 'http://ci.mycompany.com/jenkins/createItem?name=foo/bar&mode=copy&from=foo'
I find this very unusual since - through the web interface - I can easily move, copy, and create nested directories and jobs.
I am using Jenkins 1.569 with the CloudBees Folders 4.7 plugin.
name may only be a simple name. The endpoint you are looking for is on the folder, not at root level. Thus
wget --no-proxy --auth-no-challenge --http-user=username --ask-password --header="Content-Type: application/xml" --post-file="dconfig.xml" 'http://ci.mycompany.com/jenkins/job/foo/createItem?name=bar'

Resources