2

I have created a declarative jenkins pipeline and one of it's stages is as follows:

stage('Docker Image'){
        steps{
            bat 'docker build -t HMT/demo-application:%BUILD_NUMBER% --no-cache -f Dockerfile .'
        }
      }

This is the docker file:

FROM tomcat:alpine

RUN wget -O /usr/local/tomcat/webapps/launchstation04.war  http://localhost:8082/artifactory/demoArtifactory/com/demo/0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.war

EXPOSE 9100

CMD /usr/local/tomcat/bin/cataline.bat run

I am getting the below error.:

[91m/bin/sh:
01:33:28  [0mThe command '/bin/sh -c wget -O /usr/local/tomcat/webapps/launchstation04.war  http://localhost:8082/artifactory/demoArtifactory/com/demo/0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.war' returned a non-zero code: 127

UPDATE:

I have updated the command to

RUN wget -O /usr/local/tomcat/webapps/launchstation04.war -U jenkinsuser:Learning@% http://localhost:8082/artifactory/demoArtifactory/com/demo/0.0.1-SNAPSHOT/demo-0.0.1-20200823.053346-18.war

There is no problem in my command.Jfrog artifactory was unable to authorize this action.So I added username and password details but it still didn't work.

enter image description here

Error:

wget: server returned error: HTTP/1.1 401 Unauthorized

It didnt work after modifiying the password policy to unsupported.But it worked when I allowed anonymous access. How to provide access using credentials.

HMT
  • 2,093
  • 1
  • 19
  • 51

3 Answers3

1

Need more clarification on your question. Not sure where you are using curl command. Image tomcat:alpine doesn't contains curl command. Unless you install it manually.

bash-4.4# type curl
bash: type: curl: not found
bash-4.4# 

If your ask is regarding the sh -c option, if the script is invoked through CMD option, yes it will use sh. Instead you can give a try with ENTRYPOINT.

0

You can provide username & password via command line:

wget --user user --password pass

Using curl :

curl -u username:password -O

But void using special characters:

Change your password to another once in: [a-z][A-Z][0-9]

Thanh Nguyen Van
  • 10,292
  • 6
  • 35
  • 53
0

Try an API Key instead of password, I have a feeling that "@" may be throwing you off. Quotes can help there too or separating the password with -p

Also look at the request logs for whether the entry comes as 401 for the user, or anonymous/unauthenticated

Lastly, see if you can cURL from outside the image and then ADD the file in, as that will remove any external factors that may vary from the host (where I assume the command works)

AngelloMaggio
  • 504
  • 5
  • 16