GitHub Actions Workflow - workflow

I am trying to write a workflow action that will call a file (config.ini) and a directory (helm) in my GitHub repo in the first job and deploy them using a script (deploy.sh) in the second job. Can anyone help please

Related

GitHub Actions uploading and downloading artifacts

I have a Github Actions workflow which has two jobs:
Compile code to a .exe file and upload as artifact
Job that runs on Windows/Mac which downloads the .exe file and uses it.
However, all of my pipelines have failed, either because a job was for some reason canceled or because there was an error. For reference, here is my latest pipeline run: https://github.com/dantheking-crypto/MakeALanguage/actions/runs/332305074
I would appreciate it if someone could point out what I did wrong.
I took a look at your pipeline above and it seems your run-on-windows-and-mac job is missing actions/checkout action step. This is why spark.exe execution fails. It cannot find test.spark file used as an argument (it is in the repo but was not checked out to the runner executing the run). Just add the actions/checkout step before executing spark.exe spark.test and you should be fine.

How to use github files in spinnaker pipeline

Does anyone know how can we download GitHub repository as a part of spinnaker pipeline.
We have few scripts which are present in Github and I want to get those scripts during spinnaker pipeline execution.
You can use the Github artifact
You can use the Script or Run Command Stage to obtain the scripts and execute them.

Jenkins - MultiBranch Pipeline : Could not fetch branches from source

I am trying to create a Multibranch Pipeline project in Jenkins with GitHub.
In the status page of the project I have the message that says that there are no branch with the Jenkins file and not build the project, as we can see in this image:
When I scan the repository, the log shows
I configured the project with a GitHub source, as we can see in this image:
The URI of the repository,
Where in the root there is the Jenkinsfile., is:
https://github.com/AleGallagher/Prueba1
Could you help me please? I've spent many hours with this and I don't know what to do.
Thank you!
To use Multibranch pipeline it is mandatory to have Jenkinsfile in repository branch.
How it works?
The Multibranch pipeline job first scans all your repository branches and looks for Jenkinsfile, if it is able to met the criteria it will proceed by executing the Jenkinsfile code and go ahead with build, if it wont be able to find the Jenkinsfile then you will find in console that "criteria not met, jenkinsfile not found in branch".
For jenkinsfile kindly visit https://jenkins.io/doc/book/pipeline/jenkinsfile/
Recommendation:-
Choose git as an option for Branch source.
Set credentials- give preference to ssh. put privatekey as jenkins side
Make sure you have correct access to Repository, if not give access by put key of same user (ssh public-key in repository)
Let me know if issue still persists.

How to trigger nightly Jenkins pipeline job using a GitHub repository

I have a GitHub repository which contains a Jenkinsfile (with job configuration steps). I want to trigger a Jenkins simple Pipeline (not multibranch) job every night to build a jar from this repo and deploy to Nexus.
The pipeline definition options says read Pipeline script from SCM but then I don't see any option to point to specific SCM i.e. GitHub in my case. I can write the pipeline script in the Job but that is not what I want.
How can I achieve this? Please help.
You can add a build trigger for Build periodically to the jenkins job.
This will build it on a schedule for you.
You will need to install the Git Client Plugin
Then you will get the following option:
Under it you will be able to put the location of the git repo and the credentials.

How to trigger a Jenkins 2.0 Pipeline job from a GitHub pull request

It looks like the GitHubPullRequestBuilder is not compatible with Jenkins v2.0 pipeline jobs.
How do you configure a pipeline job to be triggered from a GitHub pull request event?
The documentation on this topic is sparse and I cannot find any examples of this. Or is it better to create a web-hook in GitHub to trigger the pipeline job on the PR event?
I had similar issue. Here’s what worked for me
Pre-req
Jenkins ver. 2+ (I was using Jenkins 2.60)
Github (or Githhub
enterprise) account
Your github and Jenkins must be able to talk to
each other.
On Github
create a github Personal Access Token (PAT) with relevant rights.
For your repo, create a webhook with
URL as YourJenkinsURL/github-webhook/
Choose ‘Let me select individual events’ and check ‘Pull Request’
Add a Jenkinsfile to the root folder of your repo. For testing purpose you could put content as a basic hello world like below
pipeline {
agent any
stages {
stage('Test') {
steps {
echo 'Hello World ...'
}
}
}
}
On Jenkins
Install GitHub Pull Request Builder plugin. (You also need “Github” plugin but that should normally be installed as part of Jenkins ver 2+)
Jenkins – Credentials
Add github Personal Access Token (PAT) as a ‘secret text’ credential.
Add github username-password as ‘username-password’ credential.
Manage Jenkins – Configure System
Github – Github Servers : This is part of the Github plugin. Add a github server. ‘API URL’ It will default to https://api.github.com. If you are using enterprise github, replace with enterprise github url followed by /api/v3. For credential select the PAT option. Test the connection. ‘Manage Hooks’ is checked.
GitHub Pull Request Builder : for ‘GitHub Server API URL’ use same url as specified in Github Server section. Leave ‘Shared Secret’ blank. For credentials use ‘username-password’ credential. Test credentials to ensure its working. In my settings, ‘Auto-manage webhooks’ was checked.
Pipeline Job
Create a new item using ‘Pipeline’ option. Note: This is the vanilla Pipeline job, not Multibranch Pipeline.
General Section: Check ‘Github Project’ – Project URL : Enter your github repo url
Build Triggers: Check ‘GitHub Pull Request Builder’
For ‘GitHub API credentials’ select option you set for GitHub pull request builder in ‘Manage Jenkins – Configure System’ screen
For admin list: add your username
Check Use github hooks for build triggering
Pipeline:
Select ‘Pipeline Script from SCM’. Note this assumes that the root folder of your repo will contain a ‘Jenkinsfile’
SCM: Select ‘Git’
Repositories – enter repo detail. For credentials use ‘username-password’ based credentials.
Click Advanced and add refspec as +refs/pull/*:refs/remotes/origin/pr/*
Branch – should be ${sha1}
Script Path: defaulted to Jenkinsfile, leave as is.
Lightweight Checkout - Uncheck this (https://github.com/jenkinsci/ghprb-plugin/issues/507)
That’s it. You are all set. Creating a PR on master branch of your repo should now trigger your Jenkins Pipeline job
Some observations
Redelivering the webhook payload of a PR from github does not trigger the pipeline but opening a new PR or even re-opening a closed PR on github, triggers the pipeline job
In Pipeline Job Configuration, if you choose “Pipeline Script” and paste your pipeline script in there, the job doesn't trigger !!!
The flow in a nutshell can go like this:
You create your pipeline as code and save it in a file called Jenkinsfile at the root dir of your project. That code should describe how your project will get built. See here for examples: https://jenkins.io/doc/pipeline/examples/
Then you should create a new "Multibranch Pipeline Project" item in your Jenkins. You should set this up so as to scan your repo of step 1.
Now whenever you get a new PR branch opened on your step 1 repo, the branch will be checked-out and will get built according to the Jenkinsfile instructions included with it. You can set up more conditions on what gets built and when if you want to.
Notes:
"Multibranch Pipeline Project" example documentation: https://jenkins.io/doc/book/pipeline-as-code/ (scroll down to Multibranch Pipeline Projects)
Keep in mind that getting the plugin to build a PR after commending on the PR does not work. There is a discussion analyzing this here: https://github.com/jenkinsci/gitlab-plugin/issues/298 There are workarounds (also described in that discussion) but they are quite messy to set up.
The most straightforward way to use Pipeline with GitHub pull requests is to put the script into your repository under the name Jenkinsfile and then install the GitHub Branch Source plugin. Documentation
Follow the Below Steps for Triggering Jenkins Job Automatically on Pull request generated on GitHub
Create a web hook on GitHub i.e. http:///generic-
webhook-trigger/invoke
Content Type :application/json
Select Pull Request as event Now github Configuration Part is done.
Jenkins Job Configuration
Download Generic Webhook Trigger in Jenkins
Git Hub Configuration On Jenkins
Git Hub Configuration
7.Select Generic Webhook Trigger on jenkins
8.Generic Webhook Trigger Configuration on Jenkinsand follow step 9
9.After doing step 7 Jenkins job will get trigger on PullRequest
10.Step 8 required to get information from Pull request Payload
11.Branch configuration inside Generic Webhook Trigger to get Branch details from Pull Request
Thanks