Summary:
When connecting to a plain git repository over SSH, which has no Jenkinsfiles in it, attempts to save and create a Jenkinsfile to master will not write the Jenkinsfile. However, attempts to save to a new branch work fine.
Prerequisites:
- A remote git "server" you can successfully connect to via ssh.
- A repository on same git server, which has been git init'd and has a README.md file on the master branch, but nothing else. The git history looks more or less like this:
ubuntu@ip-172-18-40-84:~/git-server/repos/per-stage-editing$ git hist * 9d80d07 (HEAD -> master) yeah
Steps to reproduce:
1. Launch Blue Ocean and select New Pipeline.
2. Select Git as your SCM, and provide a valid URL, in the form of ssh://username@1.2.3.4/path/to/git-server/repos/repo-name.
3. When Blue Ocean presents you with an SSH key to register with the Git server, do so, by adding it to /home/username/.ssh/authorized_keys
4. Click "Create Pipeline" and you'll be taken to the flow for creating your first Pipeline:
5. Click "Create Pipeline," and create a very simple, one-stage Pipeline:
6. Click "Save," provide a commit message, and leave the default setting of "Commit to master" selected. Then click Save & run.
7. The progress bar near the top will move left-to-right as expected, but you'll be taken back to the "You don't have any branches that contain a Jenkinsfile" message:
8. Check on the git server, to see if anything was created. Nothing was:
ubuntu@ip-172-18-40-84:~/git-server/repos/per-stage-editing$ git status On branch master nothing to commit, working directory clean ubuntu@ip-172-18-40-84:~/git-server/repos/per-stage-editing$ ls README.md
9. Repeat the process of creating a Pipeline. But this time, save it to a new branch, like so:
10. This time, the Jenkinsfile has been created:
11. And we can see this on the git server, too:
ubuntu@ip-172-18-40-84:~/git-server/repos/per-stage-editing$ git branch editor-created-this-branch * master ubuntu@ip-172-18-40-84:~/git-server/repos/per-stage-editing$ git checkout editor-created-this-branch Switched to branch 'editor-created-this-branch' ubuntu@ip-172-18-40-84:~/git-server/repos/per-stage-editing$ ls Jenkinsfile README.md ubuntu@ip-172-18-40-84:~/git-server/repos/per-stage-editing$ cat Jenkinsfile pipeline { agent any stages { stage('Second Attempt') { steps { echo 'Hello from editor-created-this-branch' } } } }ubuntu@ip-172-18-40-84:~/git-server/repos/per-stage-editing$
- links to