Deployment Using Jenkins task failed

would you know why publish over ssh to the storage server as natasha is not allowing to publish artifacts. I have setup everything correctly. Am I missing something

Thanks

Do you need to setup the key when configuring server for publish over SSH in the Jenkins configure system. If yes then is it the private key of the root user on ststor01?

Hi @satagrawal, I think that user Natasha cannot write to /data directly without sudo privilege.

You might try removing “/data” from “Remote Directory” then use this script:

#!/bin/bash
echo Bl@kW | sudo -S cp * /data

Thanks for you response. So is it scp * (just one star) or should it be scp ** or scp **/*. Just making sure

And in the build step just use the EXEC Command and not source files correct?

no, I meant to use normal cp after getting the files in Natasha’s home directory. The stars you made were correct and they will copy everything from build artifacts. The point is to leave “Remote Directory” blank which will put them by default in user’s home directory then you exec a command to copy them to /data.

Update: Managed to complete this task successfully now.
Observations: I was using the SCP plugin to push the build artifacts to ststor01:/data earlier. This plugin seems to be unstable as this time the plugin failed to upload the files in some iterations whereas it could in others. Could not investigate why as it seemed random. The SCP Plugin also gives security warnings and therefore it seems best to avoid it.

Instead this time, i used the SSH plugin to upload the files and it worked like a charm.

Thanks Admins @Inderpreet . Overall a good challenging task.

Hi All,

I got this task today and it worked perfectly for me.

I did the below steps which can be helpful if you are stuck anywhere:

  1. Installed Gitea plugin
  2. Added Gitea Server under “Configure System” and Manage Hooks as Yes
  3. Webhook created in Gitea UI to hit the required job when commit happens
  4. Create the required job
    4.1 Give SCM of Gitea Repo
    4.2 Make Build Triggers as Poll SCM which will get triggered from webhook
    4.3 Build Script as below:
    - git clone of the repo in /tmp directory
    - copy all the files forcefully from cloned directory to /data folder
    - clean the /tmp directory so that if job runs again it should work properly.

This is just a basic guideline for this Task.

@makadia.dhaval88 what section of the task is asking you to clone the repo? if you dont mind explaining that please?

Once the job is triggered we have to deploy the latest code. Latest code is in git and thus cloning comes into picture.
I hope it makes sense.

but you are already pushing the changes, then jobs is triggered to copy that into /data right?

The solution which I applied was to trigger Jenkins Build via Webhook and then wrote a script to execute on remote server i.e. Storage wherein I clone the git repo and copy to /data folder

1 Like

Hi,

Usually once you deploy code from any repository you never configure your deployment job to copy or update only single file (we can skip some files by keeping them in .gitignore etc though) but whatever we have under git repository it should be deployed so please make sure to configure your job to deploy the entire content of the repository on the destination, not only the index.html file. We have updated the question to make it more clear.

Also as of now we can not record your answers for Jenkins scenarios to review them further so could you please try to record your answer using some screen recording software such as loom.com ? You can directly share your answer with us in DM and we will review the same to identify the issues with this task.

Note: Avoid sharing your answers directly here on threads because we recommend others to try on their own rather than looking into the answers directly

1 Like

I am stuck on this task for days, it gets the following auth error? anyone has any ideas?

git rev-list --no-walk 165e67a938980150323bb2e4fa1ff524c577930d # timeout=10
SSH: Connecting from host [jenkins.stratos.xfusioncorp.com]
SSH: Connecting with configuration [ststor01] …
ERROR: Exception when publishing, exception message [Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [ststor01]. Message [Auth fail]]]
Build step ‘Send files or execute commands over SSH’ changed build result to UNSTABLE
Finished: UNSTABLE

When you add SSH servers you have an option to test the connection. Did you try that and confirm the connection is successfull.

the connection test is successful.

but when i try the copy script, it said authorization failed
beside the script, anything i need to do on the server?
send file over ssh
source file: */
exec command:
#!/bin/bash
sudo cp index.html /data

As per your exec command section, I think it’s failing because you are not passing the password with sudo command.
Sudo command will require the password (unless you have off this setting in the config file), and you can make use of sudo -S flag to pass the password.

I getting failure with below


Error

Git clone happens automatically for me, did not need that

Approach taken in my case was is mentioned here and as per the same “4.3 Build Scripts” were executed on App Servers and to do the same git clone was required.
Else I believe git clone would not require if it would be Jenkins Node itself where build got triggered.

I am also stuck with the same error for past one week. Can some one help me how to fix this issue. I have tried all the solution above but it didnt work. I am still getting unstable build. I have tested the connection with publish over ssh it was success. But my build is not passing through. I have give 777 permission the user i created and added the user to sudo group as well. No luck. Please help me.