Get Artifactory URL from Jenksfile and email it - jenkins-pipeline

I'm using a Jenkinsfile to upload some artifacts to Artifactory. Once this is complete, I want to be able to send an email with the download link for the artifacts. Currently, the best I can find is to send the directory where the file is and then navigate to it. Is there a way to capture the full download URL without having to go into the build log or having to find it to download it? I've include my Jenkinsfile Stage below.
stage('Artifactory') {
when{
anyOf{
branch 'UploadBranch'
}
}
steps{
rtUpload (
serverId: 'Artifactory_Server',
spec: '''{
"files": [
{
"pattern": "path/to/file/*",
"target": "Project/${BUILD_TIMESTAMP}/folder1/"
},
{
"pattern": "path/to/other/file/*",
"target": "Project/${BUILD_TIMESTAMP}/folder2/"
}
]}
'''
)
}
post {
always {
emailext attachLog: true, body: '''A new file has been uploaded into Artifactory.
Please find link below:
https://fake.artifactory.com/Project/${BUILD_TIMESTAMP}''', subject: 'New file in Artifactory', recipientProviders: [[$class: 'DevelopersRecipientProvider']]
cleanWs()
}
}
}
As you can see from the snippet above, I won't know the file name or which folder it will end up in ahead of time, so I'd need a way of capturing the upload log. Is this even something I can do in a Jenkinsfile?

I have a similar job setup, it's working fine till now.
Once you upload the artifact then follow the below steps.
Steps...
Make a Jfrog Artifact search of the recently uploaded item in a particular location e.g. in your case it's https://fake.artifactory.com/Project/${BUILD_TIMESTAMP}/folder2/
Save the output in a file or some Environment Variable.
Retrieve the value of the same Environment variable in your message.

Related

NativeScript Downloader plugin: Can not open zip file after downloading the file

I am working on native script 8 and using ns plugin add #triniwiz/nativescript-downloader plugin to download the zip file from the server.
I get the download response
"status": "completed",
"path": "file:///data/user/0/com.myapp.example/cache/1bbf6484-9c77-4357-9759-1c1a55011a21"
but when the plugin tries to unzip the same downloaded file it gives me this
File does not exist, invalid archive path: file:///data/user/0/com.myapp.example/cache/1bbf6484-9c77-4357-9759-1c1a55011a21
I am using #nativescript/zip for unzipping the downloaded file.
unZipFile(path, unzipPath) {
let destination = fs.path.join(this.document.path,"/assets/",unzipPath);
return Zip.unzip({
archive: path,
directory: destination,
onProgress: this.onUnZipProgress
}).then((res) => {
console.log(res);
return destination;
}).catch((err) => {
return 'failed-----------------:'+err;
});
}
not sure if there is something wrong with the code or the plugin, can someone please help?
Check the download directory you're using. You likely should be using only the temp or documents known folders. See the [NativeScript File System][1] docs for details.
I've seen a problem similar to this where it looks like the file downloaded successfully but in fact failed due to security restrictions. This is especially true on iOS.
[1]: https://v7.docs.nativescript.org/ns-framework-modules/file-system

Bad request when deploying smart contract

So I'm currently trying to deploy a router smart contract. I've been building it through erdpy contract build, which has been successful (I'm on rust nightly tool chain as the Smart contract needs it). And I am now trying to deploy it, but I can't manage to do it. I keep having a 400 BadRequest from https://devnet-api.elrond.com/transaction/send.
Here are the logs from the deployment:
erdpy contract deploy
INFO:accounts:Account.sync_nonce()
INFO:accounts:Account.sync_nonce() done: 0
INFO:cli.contracts:Contract address: erd1qqqqqqqqqqqqqpgqzqv7kk893c3ftwgaekvvv9whpqcfn4kazqxq3mud36
INFO:transactions:Transaction.send: nonce=0
CRITICAL:cli:Proxy request error for url [https://devnet-api.elrond.com/transaction/send]: {'statusCode': 400, 'message': 'Bad Request'}
And here is erdpy.json used to configure the command:
{
"configurations": {
"default": {
"proxy": "https://devnet-api.elrond.com",
"chainID": "D"
}
},
"contract":{
"deploy":{
"verbose": true,
"bytecode": "output/router.wasm",
"recall-nonce": true,
"nonce": 1,
"pem": "../../../wallets/owner/wallet-owner.pem",
"gas-limit": 600000000,
"send": true,
"outfile": "deploy-testnet.interaction.json"
}
}
}
The contract I'm trying to deploy is the following. I've also been through the OpenAPI Spec or the documentation searching for an answer, but there is nothing about it. This route is normally returning error message, but for this specific case it is not.
Some other contract like ping-pong are working properly with the same erdpy.json config.
After talking with someone who were interested into this issue, I ended up with the following command:
erdpy --verbose contract deploy --project=$PROJECT_NAME --pem="wallet-owner.pem" --gas-limit=600000000 --proxy="https://devnet-gateway.elrond.com" --outfile="elrond.workspace.json" --recall-nonce --send --chain="D"
Replace $PROJECT_NAME by the folder of your contract (you need to be one level upper than your smart contract folder).
It won't use the elrond.json file, but i guess you can move up the file to make the command use it.
I have you tried to deploy with the argument --verbose?
That should be something like that (not sure of the syntax because I am on phone)
erdpy --verbose contract deploy
I was getting the "bad request" error too, and I worked out that for me this was because my wallet was empty. To add xEGLD to your devnet wallet:
Go to https://devnet-wallet.elrond.com/faucet
Log in using your pem file / whatever you normally use to log in
Click the "Faucet" option from the left hand menu
This should pop up a modal to add 10 xEGLD to your wallet (You can request 10 xEGLD every 24 hours)
Now you can return to the terminal and run erdpy contract deploy
This worked for me, and now I'm getting the correct output.
In the suggested erdpy.json from Elrond Docs there is an "chainID": "D" variable inside configuration.default object.
Delete this and add inside contract.deploy this : "chain": "D".
Example
{
"configurations": {
"default": {
"proxy": "https://devnet-api.elrond.com"
"chainID": "D" <----- Delete this
}
},
"contract":{
"deploy":{
<Other fields>
"chain": "D" <----- Add this
}
}
}

How to use console log parser in jenkins pipeline project

I am new to jenkins and have build a pipeline project. In one of the stage , I build a docker image and in the next stage , I execute container-structure-test on the docker image . The test cases results can be viewed in the console output.
What I want is in the build summary page , it has a link from where I can directly view the test case results in the logs and need not to go through the complete console output. Since its not junit test cases , I could not find any straight out of the box jenkins plugin.
I came across console log parser plugin but I'm not sure how to use in jenkins declarative pipeline project . I see this option in free style project under post build action but no such option is available in pipeline project.
Could someone suggest me how I can make use of this plugin in pipeline builds to address my usecase.
You can write out the container running log to a file, then publish this file as report.
stage('Test') {
steps {
script {
out = sh(returnStdout: true,
script: '''
docker run ......
'''
)
writeFile text: out, file: 'test.log'
publishHTML([
allowMissing: true, alwaysLinkToLastBuild: false,
includes: 'test.log', keepAll: false,
reportDir: '.', reportFiles: 'test.log',
reportName: 'HTML Report'
])
}
}
}
Here is official documentation mentioning which method you should use:
https://www.jenkins.io/doc/pipeline/steps/log-parser/
You can use it anywhere, but probably you would like to use it at the end of the pipeline in the post phase.
Example:
pipeline {
// some stages here
post {
always {
logParser ([
projectRulePath: 'path/to/rules/file/on/the/node',
parsingRulesPath: '',
showGraphs: true,
unstableOnWarning: true,
useProjectRule: true
])
}
}
}

Heroku Pipeline Deploy Hook HTTP in app.json

I am setting up a Heroku pipeline and I want to add the "add-on" attribute however I did not see them be applied to my environment.
The format of the add ons block is:
"addons": [
"sendgrid",
{
"plan": "deployhooks:http",
"as": "SLACK-ENG-STATUS",
"options": {
"url": "THIS IS A RANDOM URL"
}
}
],
Is that the correct syntax to create the add-on? I do not see the configuration in the staging app when I directly deploy to it.
Do you expect your addon to be created on deploy? Because that is not how the app.json works. The app.json only created your addons for:
Review apps (https://devcenter.heroku.com/articles/github-integration-review-apps#app-json)
When you use the platform API to create your app (https://devcenter.heroku.com/articles/setting-up-apps-using-the-heroku-platform-api), including through the Heroku Button
If you already have an existing app, entries in the app.json will not modify it on deploy.

How to describe the dependencies?

Used in the project Slim + Slim/Extras + Twig.
I need to use it https://github.com/codeguy/Slim-Extras/pull/87 ,
but at the moment pull-request not accepted.
How do I properly configure the Composer?
So far, so as not to inhibit the development, fix the code in folder vendor, but this is absolutely the wrong approach.
If I understand this correctly, you need to add your own repository.
There might be problem in the same name of branch (origin: master, yours: master). Try changing your branch name if this happens.
"require": {
"slim/extras": "master"
},
"repositories": [
{ "type": "git", "url": "https://github.com/mvader/Slim-Extras.git" }
]

Resources