Unable to commit or push using GIT in pipeline job - Could not create directory '/home/SYSTEM/.ssh'












0















I have Jenkins Master and running the jobs on a Windows Slave. I am trying to push my commits to my git repo but doesn't work as expected



Below is my Pipeline script



{node('win2k12') {
def artifactTagVersion = params.TAG_VERSION
if(artifactTagVersion) { // groovy treats null or empty strings as false
print "Building in Release mode for version: ${artifactTagVersion}"
// create flag to define that release mode is active
isRelease = true
} else {
print "Building in SNAPSHOT mode"
}

stage("Checkout & Use git"){
deleteDir()
checkout scm
if(isRelease){
print "Preparing sources for releasing."
// go into headless mode
bat "git checkout --detach HEAD"
bat "echo v${artifactTagVersion} > versionFile.txt"
def commitMessage = "Release for version ${artifactTagVersion}"
sshagent(['a075b609-adaf-233d7f3be0a0']) {
bat "git add ."
bat "git commit -m "${commitMessage}""
bat "git tag -a v${artifactTagVersion} -m "${commitMessage}""
bat "git push origin v${artifactTagVersion}"
}
}
}


And this is the error i get while building



E:jenkinsslaveworkspacetest-job-trainex---dev---ts>git push origin v1
Could not create directory '/home/SYSTEM/.ssh'.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.


I have no clue, tried searching a lot for this but no one has answer on why does this look for a directory and keys when its a windows machine and the path looks like linux.










share|improve this question

























  • The issue was more about ssh keys that need to be forwarded to the windows slaves to avoid command prompt each time git fetch is executed on the slaves. My solution was to store ssh keys on slaves without passphrase and i use java web start method to launch the windows slave

    – sahoo
    Nov 16 '18 at 14:37
















0















I have Jenkins Master and running the jobs on a Windows Slave. I am trying to push my commits to my git repo but doesn't work as expected



Below is my Pipeline script



{node('win2k12') {
def artifactTagVersion = params.TAG_VERSION
if(artifactTagVersion) { // groovy treats null or empty strings as false
print "Building in Release mode for version: ${artifactTagVersion}"
// create flag to define that release mode is active
isRelease = true
} else {
print "Building in SNAPSHOT mode"
}

stage("Checkout & Use git"){
deleteDir()
checkout scm
if(isRelease){
print "Preparing sources for releasing."
// go into headless mode
bat "git checkout --detach HEAD"
bat "echo v${artifactTagVersion} > versionFile.txt"
def commitMessage = "Release for version ${artifactTagVersion}"
sshagent(['a075b609-adaf-233d7f3be0a0']) {
bat "git add ."
bat "git commit -m "${commitMessage}""
bat "git tag -a v${artifactTagVersion} -m "${commitMessage}""
bat "git push origin v${artifactTagVersion}"
}
}
}


And this is the error i get while building



E:jenkinsslaveworkspacetest-job-trainex---dev---ts>git push origin v1
Could not create directory '/home/SYSTEM/.ssh'.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.


I have no clue, tried searching a lot for this but no one has answer on why does this look for a directory and keys when its a windows machine and the path looks like linux.










share|improve this question

























  • The issue was more about ssh keys that need to be forwarded to the windows slaves to avoid command prompt each time git fetch is executed on the slaves. My solution was to store ssh keys on slaves without passphrase and i use java web start method to launch the windows slave

    – sahoo
    Nov 16 '18 at 14:37














0












0








0








I have Jenkins Master and running the jobs on a Windows Slave. I am trying to push my commits to my git repo but doesn't work as expected



Below is my Pipeline script



{node('win2k12') {
def artifactTagVersion = params.TAG_VERSION
if(artifactTagVersion) { // groovy treats null or empty strings as false
print "Building in Release mode for version: ${artifactTagVersion}"
// create flag to define that release mode is active
isRelease = true
} else {
print "Building in SNAPSHOT mode"
}

stage("Checkout & Use git"){
deleteDir()
checkout scm
if(isRelease){
print "Preparing sources for releasing."
// go into headless mode
bat "git checkout --detach HEAD"
bat "echo v${artifactTagVersion} > versionFile.txt"
def commitMessage = "Release for version ${artifactTagVersion}"
sshagent(['a075b609-adaf-233d7f3be0a0']) {
bat "git add ."
bat "git commit -m "${commitMessage}""
bat "git tag -a v${artifactTagVersion} -m "${commitMessage}""
bat "git push origin v${artifactTagVersion}"
}
}
}


And this is the error i get while building



E:jenkinsslaveworkspacetest-job-trainex---dev---ts>git push origin v1
Could not create directory '/home/SYSTEM/.ssh'.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.


I have no clue, tried searching a lot for this but no one has answer on why does this look for a directory and keys when its a windows machine and the path looks like linux.










share|improve this question
















I have Jenkins Master and running the jobs on a Windows Slave. I am trying to push my commits to my git repo but doesn't work as expected



Below is my Pipeline script



{node('win2k12') {
def artifactTagVersion = params.TAG_VERSION
if(artifactTagVersion) { // groovy treats null or empty strings as false
print "Building in Release mode for version: ${artifactTagVersion}"
// create flag to define that release mode is active
isRelease = true
} else {
print "Building in SNAPSHOT mode"
}

stage("Checkout & Use git"){
deleteDir()
checkout scm
if(isRelease){
print "Preparing sources for releasing."
// go into headless mode
bat "git checkout --detach HEAD"
bat "echo v${artifactTagVersion} > versionFile.txt"
def commitMessage = "Release for version ${artifactTagVersion}"
sshagent(['a075b609-adaf-233d7f3be0a0']) {
bat "git add ."
bat "git commit -m "${commitMessage}""
bat "git tag -a v${artifactTagVersion} -m "${commitMessage}""
bat "git push origin v${artifactTagVersion}"
}
}
}


And this is the error i get while building



E:jenkinsslaveworkspacetest-job-trainex---dev---ts>git push origin v1
Could not create directory '/home/SYSTEM/.ssh'.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.


I have no clue, tried searching a lot for this but no one has answer on why does this look for a directory and keys when its a windows machine and the path looks like linux.







git jenkins jenkins-pipeline






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 14:08







sahoo

















asked Nov 16 '18 at 12:14









sahoosahoo

13




13













  • The issue was more about ssh keys that need to be forwarded to the windows slaves to avoid command prompt each time git fetch is executed on the slaves. My solution was to store ssh keys on slaves without passphrase and i use java web start method to launch the windows slave

    – sahoo
    Nov 16 '18 at 14:37



















  • The issue was more about ssh keys that need to be forwarded to the windows slaves to avoid command prompt each time git fetch is executed on the slaves. My solution was to store ssh keys on slaves without passphrase and i use java web start method to launch the windows slave

    – sahoo
    Nov 16 '18 at 14:37

















The issue was more about ssh keys that need to be forwarded to the windows slaves to avoid command prompt each time git fetch is executed on the slaves. My solution was to store ssh keys on slaves without passphrase and i use java web start method to launch the windows slave

– sahoo
Nov 16 '18 at 14:37





The issue was more about ssh keys that need to be forwarded to the windows slaves to avoid command prompt each time git fetch is executed on the slaves. My solution was to store ssh keys on slaves without passphrase and i use java web start method to launch the windows slave

– sahoo
Nov 16 '18 at 14:37












1 Answer
1






active

oldest

votes


















0














I understood the issue, the problem is with the windows slave. So while we setup the windows slave we do set it up as a service.
While we set the windows service its better always to configure it with credentials.




  • Open services(run->services.msc)

  • Open properties for jenkins_slave process

  • click on tab "Log on"

  • Instead of System account, configure under "This account"

  • Stop and start the service again


Also instead of cygwin, install git bash which will work for the sshd services. That's it and now everything works.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337705%2funable-to-commit-or-push-using-git-in-pipeline-job-could-not-create-directory%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I understood the issue, the problem is with the windows slave. So while we setup the windows slave we do set it up as a service.
    While we set the windows service its better always to configure it with credentials.




    • Open services(run->services.msc)

    • Open properties for jenkins_slave process

    • click on tab "Log on"

    • Instead of System account, configure under "This account"

    • Stop and start the service again


    Also instead of cygwin, install git bash which will work for the sshd services. That's it and now everything works.






    share|improve this answer




























      0














      I understood the issue, the problem is with the windows slave. So while we setup the windows slave we do set it up as a service.
      While we set the windows service its better always to configure it with credentials.




      • Open services(run->services.msc)

      • Open properties for jenkins_slave process

      • click on tab "Log on"

      • Instead of System account, configure under "This account"

      • Stop and start the service again


      Also instead of cygwin, install git bash which will work for the sshd services. That's it and now everything works.






      share|improve this answer


























        0












        0








        0







        I understood the issue, the problem is with the windows slave. So while we setup the windows slave we do set it up as a service.
        While we set the windows service its better always to configure it with credentials.




        • Open services(run->services.msc)

        • Open properties for jenkins_slave process

        • click on tab "Log on"

        • Instead of System account, configure under "This account"

        • Stop and start the service again


        Also instead of cygwin, install git bash which will work for the sshd services. That's it and now everything works.






        share|improve this answer













        I understood the issue, the problem is with the windows slave. So while we setup the windows slave we do set it up as a service.
        While we set the windows service its better always to configure it with credentials.




        • Open services(run->services.msc)

        • Open properties for jenkins_slave process

        • click on tab "Log on"

        • Instead of System account, configure under "This account"

        • Stop and start the service again


        Also instead of cygwin, install git bash which will work for the sshd services. That's it and now everything works.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 14:29









        sahoosahoo

        13




        13






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337705%2funable-to-commit-or-push-using-git-in-pipeline-job-could-not-create-directory%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()